#include <stdio.h>
#include <stdbool.h>

int N,M,AB[200000][2];

int main()
{
    int record[100000]={0},n_record=0,n=0,path[100000]={0};
    record[0]=1;
    scanf("%d %d",&N,&M);
    for(int i=0;i<M;i++){
	scanf("%d %d",&AB[i][0],&AB[i][1]);
	if(AB[i][0]==1 && record[AB[i][1]-1]==0){
	    record[AB[i][1]-1]=1;
	    path[n_record]=AB[i][1]-1;
	    n_record++;
	}
	else if(AB[i][1]==1 && record[AB[i][0]-1]==0){
	    record[AB[i][0]-1]=1;
	    path[n_record]=AB[i][0]-1;
	    n_record++;
	}
    }

    for(int i=0;i<N-1;i++){
	if(path[i]==0)
	    break;
	if(n_record==N-1)
	    break;
	for(int j=0;j<M;j++){
	    if(AB[j][0]==path[i]+1 && record[AB[j][1]-1]==0){
		record[AB[j][1]-1]=path[i]+1;
		path[n_record]=AB[j][1]-1;
		n_record++;
	    }
	    else if(AB[j][1]==path[i]+1 && record[AB[j][0]-1]==0){
		record[AB[j][0]-1]=path[i]+1;
		path[n_record]=AB[j][0]-1;
		n_record++;
	    }

	}
    }

    if(n_record==N-1){
	puts("Yes");
    	for(int i=1;i<N;i++)
    	    printf("%d\n",record[i]);
    }
    else
	puts("No");

    return 0;
}

