#include<stdio.h>
int first[1000000];
int next[1000000];
int go[1000000];
int ans[1000000];
int visited[1000000];
int q[1000000];
int i,n,m,x,y,flag,re,t,l,r;

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;
	}
    l=0;r=1;
    q[1]=1;
    visited[1]=1;
    while (l<r){
    	l++;
    	re=q[l];
    	t=first[re];
    //	printf("%d\n",re);
    	while (t!=0){
    		if (visited[go[t]]==0){
    			visited[go[t]]=1;
    			r++;
    			q[r]=go[t];
    			ans[go[t]]=re;
			}
    		t=next[t];
		}
	}
    flag=0;
    for (i=2;i<=n;i++)
      if (visited[i]==0){
      	flag=1;
	  }
	if (flag==1){
		printf("No\n");
	}else{
	printf("Yes\n");
    for (i=2;i<=n;i++){
    	printf("%d\n",ans[i]);
	}
}
} 