#include<stdio.h>
#define M 1000000
int first[M], next[M], go[M], ans[M], visited[M], q[M];
int i, n, m, x, y, flag = 0, re, t, l = 0, r = 1;
int main(){
	scanf("%d %d",&n,&m);
	for(i = 1; i <= m; i++){
		scanf("%d %d",&x,&y);
		next[i] = first[x];
		first[x] = i;
		go[i] = y;
		next[i + m] = first[y];
		first[y] = i + m;
		go[i + m] = x;
	}
    q[1] = 1;
    visited[1] = 1;
    while(l < r){
    	l++;
    	re = q[l];
    	t = first[re];
    	while(t){
    		if(!visited[go[t]]){
    			visited[go[t]] = 1;
    			r++;
    			q[r] = go[t];
    			ans[go[t]] = re;
			}
    		t = next[t];
		}
	}
    for(i = 2; i <= n; i++)
      if(!visited[i])
        flag = 1;
	if(flag)
		puts("No");
	else{
    	puts("Yes");
        for (i = 2; i <= n; i++)
    	    printf("%d\n",ans[i]);
    }
} 