#include<stdio.h>
int fr[200010],ta[200020],to[400040],nt[400040];
void f(int s){printf("!%d\n",s);
  int i;
  for(i=ta[s];i+1;i=nt[i]){
    if(fr[to[i]]!=-1)continue;
    fr[to[i]]=s;
    f(to[i]);
  }
}
int main(){
  int n,m,i,j,a,b,q[200010],t,r=1;
  scanf("%d %d",&n,&m);
  for(i=1;i<=n;i++)ta[i]=fr[i]=-1;
  for(i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    nt[i  ]=ta[a];
    nt[i+m]=ta[b];
    to[i  ]=b;
    to[i+m]=a;
    ta[a]=i;
    ta[b]=i+m;
  }
  /* for(i=0;i<n;i++){printf("%d:",i+1);
    for(j=ta[i];j+1;j=nt[j])printf("%d ",to[j]);printf("\n");
    }//*/
  q[t=0]=1;
  for(r=1;r-t;t++){
    for(i=ta[q[t]];i+1;i=nt[i]){
      if(fr[to[i]]!=-1)continue;
      fr[to[i]]=q[t];
      q[r++]=to[i];
    }
  }  
  printf("Yes\n");
  for(i=2;i<=n;i++)printf("%d\n",fr[i]);
  return 0;
}
