#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t N, M;
  cin >> N >> M;
  vector<vector<int64_t>> root(N, vector<int64_t>(N));
  for (int64_t i = 0; i < M; i++) {
    int64_t a, b;
    cin >> a >> b;
    root[a - 1][b - 1] = 1;
    root[b - 1][a - 1] = 1;
  }
  queue<int64_t> a;
  a.push(0);
  vector<int64_t> check(N);
  vector<int64_t> arrange(N);
  check[0] = 1;
  int64_t l;
  int64_t count = 0;
  while (a.size() != 0) {
    l = a.front();
    for (int64_t i = 0; i < N; i++) {
      if (root[l][i] == 1 && check[i] == 0) {
        arrange[i] = l;
        a.push(i);
        check[i] = 1;
        count++;
      }
      if (count == N - 1) {
        break;
      }
    }
    if (count == N - 1) {
      break;
    }
    a.pop();
  }
  for (int64_t i = 0; i < N; i++) {
    if (check[i] == 0) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes" << endl;
  for (int64_t i = 1; i < N; i++) {
    cout << arrange[i] + 1 << endl;
  }
}
