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

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

int queue[200200];
long qlen,qhead;

void enqueue(int n){
    queue[qhead+qlen >= 200200 ? (qhead+qlen) % 200200 : qhead+qlen] = n;
    qlen++;
}

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

int main(void){
    register int i;
    int n,m;
    scanf("%d%d",&n,&m);
    for(i = 0;i < m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        x--; y--;
        ars[x] = realloc(ars[x],arl[x]+1);
        ars[y] = realloc(ars[y],arl[y]+1);
        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("%d\n",ans[i]+1);
}