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

vector<int> g[100000];
int ans[100000];
void bfs() {
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (int to: g[cur]) {
      if (to != 0 && ans[to] == -1) {
        ans[to] = cur;
        q.push(to);
      }
    }
  }
}
int main() {
  int n, m;
  cin>>n>>m;
  for (int i=0; i<m; i++) {
    int a, b;
    cin>>a>>b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i=0; i<n; i++) ans[i] = -1;
  bfs();
  cout<<"Yes"<<endl;
  for (int i=1; i<n; i++) {
    cout<<ans[i]+1<<endl;
  }
}