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

int main(){
  int N,M,a,b;
  cin>>N>>M;
  int D[N];
  int B[N];
  vector<int>G[N];
  for(int i=0;i<N;i++){
    D[i]=INF;
    B[i]=-1;
  }
  
  for(int i=0;i<M;i++){
    cin>>a>>b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  queue<int>Q;
  D[0]=0;
  Q.push(0);
  int u;
  
  while(!Q.empty()){
    u=Q.front();Q.pop();
    for(int i=0;i<G[u].size();i++){
      int v=G[u][i];
      if(D[v]!=INF) continue;
      D[v]=D[u]+1;
      B[v]=u;
      Q.push(v);
    }
  }  
  
  cout<<"Yes"<<endl;
  for(int i=1;i<N;i++){
    cout<<B[i]+1<<endl;
  }
  return 0;
}
