#include <bits/stdc++.h>
using namespace std;
 
const int INF=10000000;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int>to[100005];
  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);
  }
  
  queue<int>q;
  vector<int>dist(n,INF);
  vector<int>pre(n,-1);
  dist[0]=0;
  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++){
    int ans=pre[i];
    ans++;
    cout << ans << endl;
  }
}