#include <bits/stdc++.h>
using namespace std;
long depth[100000];
long mark[100000];
long road[200000][2];
long n, m;
long i, d, j;
int main() {
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> road[i][0] >> road[i][1];
  }
  for (i = 0; i < m; i++) {
    depth[i] = 300000;
  }
  depth[0] = 1;
  bool end_flag;
  for (d = 1; d < n; d++) {
    end_flag = true;
    for (i = 0; i < n; i++) {
      if (depth[i] == d) {
        end_flag = false;
        for (j = 0; j < m; j++) {
          if (road[j][0] - 1 == i && depth[road[j][1] - 1] > d) {
            depth[road[j][1] - 1] = d + 1;
            mark[road[j][1] - 1] = i;
          }
          if (road[j][1] - 1 == i && depth[road[j][0] - 1] > d) {
            depth[road[j][0] - 1] = d + 1;
            mark[road[j][0] - 1] = i;
          }
        }
      }
    }
    if (end_flag) break;
  }
  bool f_ok = true;
  for (i = 0; i < n; i++) {
    if (depth[i] >= 300000) f_ok = false;
  }
  if (f_ok) {
    cout << "Yes" << endl;
    for (i = 1; i < n; i++) {
      cout << mark[i] + 1 << endl;
    }
  } else {
    cout << "No" << endl;
  }
}
