#include<cstdio> #include<cctype> #include<set> intread(){ registerint x = 0; registerchar f = 1, ch = getchar(); for (; !isdigit(ch); ch = getchar()) if (ch == '-') f ^= 1; for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0'); return f ? x : -x; } #define N 200005 int n, m, h, t, Q[N], cnt, x[N], y[N]; std :: set<int> num, E[N]; intmain(){ n = read(), m = read(); for (registerint i = 1; i <= m; ++i){ int x = read(), y = read(); E[x].insert(y), E[y].insert(x); } for (registerint i = 2; i <= n; ++i) num.insert(i); h = 0, t = 1, Q[t] = 1; while (h < t){ int u = Q[++h]; for (auto it = num.begin(), It = it; it != num.end(); ) // 遍历,注意 auto 需要 C++11 if (!E[u].count(*it)) x[++cnt] = u, y[cnt] = *it, Q[++t] = *it, It = it, ++it, num.erase(It); else ++it; } if (num.size()) printf("No\n"); else{ printf("Yes\n"); for (registerint i = 1; i <= cnt; ++i) printf("%d %d\n", x[i], y[i]); } }