#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  int n, m;
  cin >> n >> m;

  map<int, set<int> > p;
  vector<int> ans(m + 1);
  for (int i = 1; i <= m; i++) {
    int a, b;
    cin >> a >> b;
    p[a].insert(b);
    p[b].insert(a);
  }

  int i = 1;
  queue<int> q;

  while (p.size() != 0) {
    while (p[i].size() != 0) {
      int x = *begin(p[i]);
      if (ans[x] == 0) {
        ans[x] = i;
        q.push(x);
      }
      p[i].erase(x);
    }
    p.erase(i);
    i = q.front();
    q.pop();
  }

  cout << "Yes" << endl;
  for (int i = 2; i <= n; i++) cout << ans[i] << endl;
}