#include<stdio.h>
#include<stdlib.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int sz=1e5;
int qLen,qHead,Q[sz],*cave[sz];
void PUSH(int n){Q[(qHead+qLen)%sz]=n;qLen++;}
int POP(void){int q=Q[qHead];qLen--;qHead=(qHead+1)%sz;return q;}
int main(void)
{
  int A,B,N,M,x,y;
  x=scanf("%d %d",&N,&M);
  int room[N],path[N];
  rep(i,N)path[i]=0,room[i]=-1;
  rep(i,M)
  {
    x=scanf("%d %d",&A,&B);A--,B--;
    cave[A]=(int*)realloc(cave[A],sizeof(int)*(path[A]+1));
    cave[A][path[A]]=B;path[A]++;
    cave[B]=(int*)realloc(cave[B],sizeof(int)*(path[B]+1));
    cave[B][path[B]]=A;path[B]++;
  }
  room[0]=0;PUSH(0);
  while(qLen)
  {
    x=POP();
    rep(i,path[x]){y=cave[x][i];if(!(room[y]<0))continue;room[y]=x,PUSH(y);}
  }
  puts("Yes");rep(i,N-1)printf("%d\n",room[i+1]+1);
}