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

long arl[200200];
long *ars[200200];
long ans[200200];

long queue[200200];
long qlen,qhead;

void enqueue(long n){
    queue[(qhead+qlen) % 200200] = n;
    qlen++;
}

long dequeue(void){
    long ret = queue[qhead];
    qlen--;
    qhead = (qhead+1) % 200200;
    return ret;
}

int main(void){
    register long i;
    long n,m;
    scanf("%ld%ld",&n,&m);
    for(i = 0;i < m;i++){
        long x,y;
        scanf("%ld%ld",&x,&y);
        x--; y--;
        ars[x] = realloc(ars[x],sizeof(long) * (arl[x]+1));//sizeof()!!!!!!!!!!!!!!
        ars[y] = realloc(ars[y],sizeof(long) * (arl[y]+1));//sizeof()!!!!!!!!!!!!!!
        ars[x][arl[x]] = y;
        ars[y][arl[y]] = x;
        arl[x]++;
        arl[y]++;
    }
    for(i = 0;i < n;i++)ans[i] = -1;
    enqueue(0);
    while(qlen){
        int cur = dequeue();
        for(i = 0;i < arl[cur];i++)if(ans[ars[cur][i]] == -1){
            ans[ars[cur][i]] = cur;
            enqueue(ars[cur][i]);
        }
    }
    puts("Yes");
    for(i = 1;i < n;i++)printf("%ld\n",ans[i]+1);
}