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

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

int q1[100100],ql1,qs1;
int q2[100100],ql2,qs2;

void qin1(int n){
    q1[(ql1+qs1) % 100100] = n;
    ql1++;
}

int qout1(void){
    int ret = q1[qs1];
    qs1++;
    qs1 %= 100100;
    ql1--;
    return ret;
}

void qin2(int n){
    q2[(ql2+qs2) % 100100] = n;
    ql2++;
}

int qout2(void){
    int ret = q2[qs2];
    qs2++;
    qs2 %= 100100;
    ql2--;
    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;
    qin1(0);
    qin2(0);
    while(ql1){
        int j;
        int cur = qout1();
        int from = qout2();
        if(ans[cur] != -1)continue;
        if(cur)ans[cur] = from;
        else ans[cur] = 1;
        for(j = 0;j < arl[cur];j++){
            if(ans[ars[cur][j]] == -1){
                qin1(ars[cur][j]);
                qin2(cur);
            }
        }
    }
    puts("Yes");
    for(i = 1;i < n;i++)printf("%d\n",ans[i]+1);
}