#include <bits/stdc++.h>
using namespace std;
const int INF=100100100;
int main(){
  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> to(n);
  for(int i=0; i<m; i++){
    int a, b;
    cin >> a >> b;
    a--,b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  
  vector<int> dist(n,INF);
  dist[0]=0;
  vector<int> pre(n, -1);
  queue<int> q;
  q.push(0);
  
  while(!q.empty()){
    int v = q.front(); q.pop();
    for(int u : to[v]){
      if(dist[u]!=INF) continue;
      dist[u] = dist[v] + 1;
      pre[u] = v;
      q.push(u);
    }
  }
   
    cout << "Yes" << endl;
  for(int i=1; i<n; i++){
    cout << pre[i]+1 << endl;
  }
    return 0;
  }