#include <bits/stdc++.h>
using namespace std;
int hd[100007], to[400007], nxt[400007], en;
inline void adde(int a, int b) {
  nxt[en] = hd[a];
  hd[a] = en;
  to[en] = b;
  en++;
}
queue<int> q;
bool vis[100007];
int fa[100007];
inline int bfs(int x) {
  q.push(x);
  int cnt = 1;
  memset(vis, 0, sizeof vis);
  vis[1] = 1;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (int i = hd[now]; ~i; i = nxt[i])
      if (!vis[to[i]]) {
        int t = to[i];
        cnt++;
        vis[t] = 1;
        fa[t] = now;
        q.push(t);
      }
  }
  return cnt;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  en = 0;
  memset(hd, -1, sizeof hd);
  while (0 < m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    adde(a, b);
    adde(b, a);
  }
  int cnt = bfs(1);
  if (cnt == n) {
    puts("Yes");
    for (int i = (2); i <= (n); i++) {
      printf("%d\n", fa[i]);
    }
  } else
    puts("No");
}
