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

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

int main()
{
    int record[200000]={0},n_record=0,n=0;
    bool ans=false;
    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[0]=1;
	    record[AB[i][1]-1]=1;
	    n_record++;
//	    printf("AB[%d][1]=%d\n",i,AB[i][1]);
	}
	else if(AB[i][1]==1 && record[AB[i][0]-1]==0){
	    record[0]=1;
	    record[AB[i][0]-1]=1;
	    n_record++;
//	    printf("AB[%d][0]=%d\n",i,AB[i][0]);
	}
    }
//    printf("n_record=%d\nrecord[2-1]=%d\n",n_record,record[1]);

    while(n<=N){
	for(int i=1;i<N;i++){
//	    printf("n=%d,record[%d]=%d\n",n,i,record[i]);
	    if(record[i]!=0){
		for(int j=0;j<M;j++){
		    if(AB[j][0]==i+1 && record[AB[j][1]-1]==0/* && (AB[j][1]-1)!=0*/){
//			printf("AB[%d][0]=%d\n",j,AB[j][0]);
			record[AB[j][1]-1]=i+1;
			n_record++;
		    }
		    else if(AB[j][1]==i+1 && record[AB[j][0]-1]==0/* && (AB[j][0]-1)!=0*/){
//			printf("AB[%d][1]=%d\n",j,AB[j][1]);
			record[AB[j][0]-1]=i+1;
			n_record++;
		    }
		}
	    }
	}
	if(n_record==N-1)
	    break;
	n++;
    }

//    for(int i=1;i<N;i++)
//	printf("record[%d]=%d\n",i,record[i]);

//    printf("n_record=%d\n",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;
}

