// 吉林大学11机试
// 九度:1019
// 并查集判断无向图是否连通
#include <stdio.h>
#define SIZE 1005
int fa[SIZE];
int sum[SIZE];
int Getfa(int x)
{
if(x == fa[x])
return x;
else
fa[x] = Getfa(fa[x]);
return fa[x];
}
void Init()
{
for(int i=0; i<SIZE; i++)
{
fa[i]=i;
sum[i]=1;
}
}
int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("E:\\in.txt", "r", stdin);
//freopen("E:\\out.txt", "w", stdout);
#endif
int n, m;
while(scanf("%d%d", &n ,&m) && n)
{
Init();
int x, y;
int a, b;
while(m-->0)
{
scanf("%d%d", &x, &y);
a=Getfa(x);
b=Getfa(y);
if(a != b)
{
fa[a]=b;
sum[b]+=sum[a];
}
}
//printf("%d\n", sum[b]);
puts(sum[b] == n? "YES":"NO");
}
return 0;
}