#include <bits/stdc++.h>
using namespace std;
long long N, M;
bool visited[100005];
queue<long long> q;
vector<long long> v[100005];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> N >> M;
  bool flag = false;
  for (long long i = 0; i < M; i++) {
    long long r1, r2;
    cin >> r1 >> r2;
    v[r1].push_back(r2);
    v[r2].push_back(r1);
    if (r1 == 1 || r2 == 1) flag = true;
  }
  if (!flag) {
    cout << "No"
         << "\n";
  } else {
    vector<long long> ans(N + 1);
    q.push(1);
    while (q.size()) {
      long long tmp = q.front();
      q.pop();
      if (!visited[tmp]) {
        visited[tmp] = true;
        for (long long i : v[tmp]) {
          q.push(i);
          if (ans[i] == 0) {
            ans[i] = tmp;
          }
        }
      }
    }
    cout << "Yes"
         << "\n";
    for (long long i = 2; i <= N; i++) {
      cout << ans[i] << "\n";
    }
  }
}
