#include<stdio.h>
#define NMAX 100100
int inputi(){
	char c='0';
	int ans=0;
	signed char flg=1;
	do{
		c=getchar();
	}while(c<=32);
	if(c=='-'){
		flg=-1;
		c=getchar();
	}
	do{
		ans*=10;
		ans+=(c-'0');
		c=getchar();
	}while(c>32);
	return ans*flg;
}
int main(void){
	int n,m,a,b;
	int list[5*NMAX]={0};
	int last=NMAX;
	int node[5*NMAX]={0};
	int queue[5*NMAX]={0},qfirst=0,qlen=0;;
	int room[NMAX]={0};
	int i;
	int now,tmp;
	n=inputi();
	m=inputi();
	for(i=0;i<m;i++){
		a=inputi();
		b=inputi();
		list[last]=list[a];
		list[a]=last;
		node[last]=b;
		last++;
		list[last]=list[b];
		list[b]=last;
		node[last]=a;
		last++;
	}
	queue[0]=1;qlen=1;
	room[1]=room[0]=-1;
	while(qlen){
		now=queue[qfirst];
		qlen--;
		qfirst++;
		tmp=now;
		
		while(tmp){
			tmp=list[tmp];
			if(room[node[tmp]]==0){
				room[node[tmp]]=now;
				queue[(qfirst+qlen)%(5*NMAX)]=node[tmp];
				qlen++;
			}
		}
	}
	puts("Yes");
	for(i=2;i<=n;i++){
		printf("%d\n",room[i]);
	}
	return 0;
}
