#include <stdio.h> int parents[1001]; int find(int x) { return x == parents[x] ? x : (parents[x] = find(parents[x])); } int main() { int n, m; Label: while (scanf("%d%d", &n, &m) != EOF) { if (n == 0 && m == 0) break; for (int i = 1; i <= n; i++) parents[i] = i; while (m--) { int x, y; scanf("%d%d", &x, &y); x = find(x), y = find(y); if (x != y) parents[x] = y; } int parent = find(1); for (int i = 2; i <= n; i++) { if (find(i) != parent) { printf("NO\n"); goto Label; } parents[i] = parent; } printf("YES\n"); } return 0; }