#include<stdio.h>
int main()
{
  int n,m,j,i;
  scanf("%d %d",&n,&m);
  
  int a[m],b[m],c[n],hata[n],l;
  
  l=0;
  
   for(i=0;i<n;++i)
  {
  c[i]=0;
  hata[i]=0;
  }
  
  
  for(i=0;i<m;++i)
  {
  scanf("%d %d",&a[i],&b[i]);
    
    if(a[i]==1) {
        
                          hata[b[i]-1]=1;
                          c[b[i]-1]=1;
                           l++;
                         
                    }
     else if(b[i]==1) { 
       
                          hata[a[i]-1]=1;
                          c[a[i]-1]=1;
                           l++;
                         
                    }
  }
  
  j=1;
  while(l<n)
  {
      for(i=0;i<m;++i)
     {
       if(c[a[i]-1]==j) {
         if(c[b[i]-1]==0){
                          hata[b[i]-1]=a[i];
                          c[b[i]-1]=j+1;
                           l++;
                         }
                    }
    else  if(c[b[i]-1]==j) { 
         if(c[a[i]-1]==0){
                          hata[a[i]-1]=b[i];
                          c[a[i]-1]=j+1;
                           l++;
                         }
                    }
      }
  j++;
  }
  
  printf("Yes\n");

  for(i=1;i<n;++i)
  {
  printf("%d\n",hata[i]);
  }

return 0;
}