include[HTML_REMOVED]
using namespace std;
int n, m;
int x, y;
int visited[1010],graph[1010][1010];
int list[1010][1010],listnode[1010];
int bfs(int graph[][1010], int node, int v){
//v 是起始遍历点 若广度遍历到的点数不足n则非连通图
for(int i = 1; i <= n; i) visited[i] = 0;
//cout << v << “\n”;
int queue[1010];
int front = -1, rear = -1;
queue[rear] = v;
visited[v] = 1;
//cout << front << ” ” << rear << “\n”;
while(front != rear){
int u = queue[front];
node ;
for(int i = 0; i < listnode[u]; i)
{
int p = list[u][i];// cout << visited[p] << “\n”;
if(visited[p] == 0){
queue[rear] = p;
//cout << p << “\n”;
visited[p] = 1;
}
}
}
return node;
}
int main(){
while(cin >> n >> m){
for(int i = 0; i <= n; i)
{
listnode[i] = 0;
for(int j = 0; j <= n; j)
{
graph[i][j] = 0;
list[i][j] =0;
}
}//初始化
while(m–){
cin >> x >> y;
if(!graph[y][x]&& !graph[x][y]&& (x != y)){
list[x][listnode[x]] = y;
list[y][listnode[y]] = x;//模仿吉大图的存储结构
//cout << y << ” ” << x << “\n”;
}
graph[x][y] = 1;
}
int node = bfs(graph, 0, 1);
//cout << node<< “\n”;
if (node == n) cout << “YES”;
else cout << “NO”;
cout << “\n”;
}
}