#include <bits/stdc++.h>
using namespace std;
struct room {
  vector<int> edge;
  int visited = -1;
  int sign = 0;
};
int main(void) {
  int n, m;
  room r[100005];
  cin >> n >> m;
  queue<int> q;
  int a, b;
  while (m--) {
    cin >> a >> b;
    r[a].edge.push_back(b);
    r[b].edge.push_back(a);
  }
  q.push(1);
  r[1].visited = 0;
  int x, elen;
  while (!q.empty()) {
    x = q.front();
    q.pop();
    for (int i : r[x].edge) {
      if (r[i].visited == -1) {
        r[i].visited = r[x].visited + 1;
        r[i].sign = x;
        q.push(i);
      }
    }
  }
  for (int i = 2; i <= n; i++) {
    if (r[i].visited == -1) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  for (int i = 2; i <= n; i++) {
    cout << r[i].sign << endl;
  }
  return 0;
}
