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

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

int queue[100100];
int qlen,qhead;

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

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

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