#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, i;
  vector<int> x[100005];
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    x[a].push_back(b);
    x[b].push_back(a);
  }
  vector<int> t(n, -1);
  t[0] = 1;
  queue<int> q;
  vector<int> pre(n);
  pre[0] = -1;
  int u = x[0].size();
  for (i = 0; i < u; i++) {
    pre[x[0][i]] = 0;
  }
  q.push(0);
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    t[p] = 1;
    int r = x[p].size();
    for (i = 0; i < r; i++) {
      if (t[x[p][i]] == -1) {
        q.push(x[p][i]);
        pre[x[p][i]] = p;
      }
    }
  }
  for (i = 1; i < n; i++) {
    if (t[i] == -1) {
      break;
    }
  }
  if (i != n) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
    for (int j = 1; j < n; j++) {
      cout << pre[j] + 1 << endl;
    }
  }
  return 0;
}
