#include<stdio.h>
#define NMAX 100100
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; 	scanf("%d%d",n,m) 	for(i=0;i<m;i++){ 		scanf("%d%d",a,b) ;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; } 
