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

struct graph{
	int point;
	int num;
	int *node;
};

int main(void){
	int n,m;
	scanf("%d %d",&n,&m);
	
	struct graph *pointer[n];
	
	//構造体の作成
	for(int i=0;i<n;i++){
		pointer[i]=(struct graph*)malloc(sizeof(struct graph));
		pointer[i]->point=i+1;
		pointer[i]->node=(int*)malloc(m*sizeof(int));
		pointer[i]->num=0;
	}
	
	//入力
	int temp1,temp2;
	for(int i=0;i<m;i++){
		scanf("%d",&temp1);
		scanf("%d",&temp2);
		pointer[temp1-1]->node[pointer[temp1-1]->num]=temp2-1;
		pointer[temp1-1]->num+=1;
		pointer[temp2-1]->node[pointer[temp2-1]->num]=temp1-1;
		pointer[temp2-1]->num+=1;
	}
	
	int *list,*que;
	int head=0,tail=0;
	
	que=(int*)malloc(n*sizeof(int));	
	list=(int*)malloc(n*sizeof(int));
	
	for(int i=0;i<n;i++){
		list[i]=-1;
	}
	
	que[0]=0;
	list[0]=0;
	tail=1;
	
	do{
		for(int i=0;i<pointer[que[head%n]]->num;i++){
			if(list[pointer[que[head%n]]->node[i]]==-1){
				list[pointer[que[head%n]]->node[i]]=que[head%n];
				que[tail%n]=pointer[que[head%n]]->node[i];
				tail+=1;
			}
		}
		/*for(int i=head;i<tail;i++){
			printf("%d ",que[i]);
		}
		printf("\n");*/

		head+=1;
	}while(head!=tail);
	
	printf("Yes\n");
	for(int i=1;i<n;i++){
		printf("%d\n",list[i]+1);
	}
	
	return 0;
}