#include <bits/stdc++.h>
using namespace std;
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template <class T>
inline bool chmin(T& a, T b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void execute();
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  execute();
  return 0;
}
void execute() {
  int N, M;
  cin >> N >> M;
  multimap<int, int> route;
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    route.insert(multimap<int, int>::value_type(A, B));
    route.insert(multimap<int, int>::value_type(B, A));
  }
  int frm[200001] = {};
  queue<int> que;
  ;
  int find_num = 1;
  frm[1] = 1;
  que.push(1);
  while (!que.empty()) {
    int v = que.front();
    que.pop();
    auto p = route.equal_range(v);
    for (auto it = p.first; it != p.second; ++it) {
      int idx = it->second;
      if (frm[idx] == 0) {
        frm[idx] = v;
        que.push(idx);
        if (++find_num == N) {
          cout << "Yes"
               << "\n";
          for (int i = 2; i <= N; i++) {
            cout << frm[i] << "\n";
          }
          return;
        }
      }
    }
  }
  cout << "No"
       << "\n";
}
