#include <bits/stdc++.h>
using namespace std;
int main() {
  int i;
  int m, n;
  cin >> n >> m;
  vector<int> data[100005];
  vector<int> pre(n, -1);
  vector<int> dist(n, -1);
  for (i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    data[a].push_back(b);
    data[b].push_back(a);
    ;
  }
  queue<int> que;
  dist[0] = 0;
  que.push(0);
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    for (int m : data[v]) {
      if (dist[m] != -1) continue;
      dist[m] = dist[v] + 1;
      pre[m] = v;
      que.push(m);
    }
  }
  cout << "yes" << endl;
  for (i = 1; i < n; i++) {
    cout << pre.at(i) + 1 << endl;
  }
  return 0;
}
