#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> v[100001];
int vis[100001];
int sig[100001];
void bfs(int root) {
  queue<int> q;
  q.push(root);
  while (q.size() != 0) {
    int si = q.size();
    while (si--) {
      int ele = q.front();
      q.pop();
      for (int child : v[ele]) {
        if (vis[child] == 0) {
          vis[child] = 1;
          q.push(child);
          sig[child] = ele;
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, a, b;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  sig[1] = 1;
  vis[1] = 1;
  bfs(1);
  cout << "Yes\n";
  for (int i = 2; i <= n; i++) {
    cout << sig[i] << endl;
  }
  return 0;
}
