#include<stdio.h>
#include<stdlib.h>

typedef struct{
	int one;
	int ano;
} road;

int *room,*step,*init;
road *r;

int comp(const void *p1,const void *p2);
void memoRoutes(int now);

int main(void){
	int n,m,i,tmp;

	scanf("%d%d",&n,&m);
	room=(int *)calloc(n+1,sizeof(int));
	step=(int *)calloc(n+1,sizeof(int));
	init=(int *)calloc(n+1,sizeof(int));
	r=(road *)calloc(2*m,sizeof(road));
	for(i=0;i<m;i++){
		scanf("%d%d",&r[i].one,&r[i].ano);
		r[m+i].one=r[i].ano;
		r[m+i].ano=r[i].one;
	}
	qsort(r,2*m,sizeof(road),comp);
	tmp=1;
	for(i=0;i<2*m;i++){
		if(tmp<r[i].one){
			tmp=r[i].one;
			init[tmp]=i;
		}
	}
	/*
	puts("");
	for(i=0;i<2*m;i++){
		printf("%d %d\n",r[i].one,r[i].ano);
	}
	puts("");
	//*/
	step[1]=1;
	for(i=2;i<=n;i++){
		step[i]=100001;
	}
	memoRoutes(1);
	for(i=2;i<=n;i++){
		//printf("room: %d => %d\n",i,room[i]);
		if(room[i]==0){
			room[0]=1;
			break;
		}
	}
	if(room[0]==1){
		puts("No");
	}else{
		puts("Yes");
		for(i=2;i<=n;i++){
			printf("%d\n",room[i]);
		}
	}
	free(room);
	free(step);
	free(r);
	return 0;
}

int comp(const void *p1,const void *p2){
	const road *d1,*d2;
	d1=(const road *)p1;
	d2=(const road *)p2;
	if(d1->one==d2->one){
		return d1->ano-d2->ano;
	}else{
		return d1->one-d2->one;
	}
}

void memoRoutes(int now){
	int i;
	for(i=init[now];r[i].one==now;i++){
		//printf("now: %d, step: %d, searchFor: %d\n",now,step[now],r[i].ano);
		//printf("step[%d]: %d\n",r[i].ano,step[r[i].ano]);
		if(step[r[i].ano]>step[now]){
			room[r[i].ano]=now;
			step[r[i].ano]=step[now]+1;
			memoRoutes(r[i].ano);
		}
	}
}
