#include <bits/stdc++.h>
#define MAX 1000
using namespace std;

typedef struct{
	int a,b;
}Road;
Road roads[MAX];
int vexset[MAX];
int getroot(int a){
	while(a != vexset[a])
		a = vexset[a];
	return a;
}

int main(){
	int n,m,i,a,b;
	while(cin>>n>>m){//n是顶点数,m是边数 
		if(n == 0 && m == 0)
			break;
		for(i = 0; i < n; i++){	//初始化每个节点 
			vexset[i] = i;
		}
		for(i = 0; i < m; i++){
			cin>>roads[i].a>>roads[i].b;	//初始化边	
		}	
		for(i = 0; i < m; i++){
			a = getroot(roads[i].a);
			b = getroot(roads[i].b);
			if(a != b){
				vexset[a] = b;
			}
		}
		int sum = 0;
		for(i = 0; i < n; i++){
			if(getroot(i) == i)
				sum += 1;
		}
		if(sum > 1)
			cout<<"NO"<<endl;
		else 
			cout<<"YES"<<endl;
	}

	
}