#include<stdio.h>
#define size 100000
#define fin 100000

int N,M,nm=-1,ji=-1;
int*dist[size];
int city[size];
int qu[size];
int dist_s[size];

void set(){
  int a,b;
  for(int i=0;i<N;i++){
    city[i]=-1;
    dist_s[i]=0;
  };
  city[0]=0;
  for(int i=0;i<M;i++){
    scanf("%d%d",&a,&b);
    a--;b--;
    dist[a]=realloc(dist[a],sizeof(dist_s[a]+1));
     dist[a][dist_s[a]]=b;
      dist_s[a]++;
    dist[b]=realloc(dist[b],sizeof(dist_s[b]+1));
     dist[b][dist_s[b]]=a;
      dist_s[b]++;
  };
};

int system(){
  int tar=0;
  while(1){
    for(int i=0;i<dist_s[tar];i++){
      if(city[dist[tar][i]]==-1){
        city[dist[tar][i]]=tar+1;
        nm++;
        qu[nm]=dist[tar][i];
      };
    };
    if(nm==ji)return 0;
    ji++;
    tar=qu[ji];
  };
};
    
int main(void){
   scanf("%d%d",&N,&M);
   set();
   if(system()!=0)return -1;
   printf("Yes\n");
   for(int i=1;i<N;i++){
     printf("%d\n",city[i]);
   };
  
  return 0;
}