#include <stdio.h>
#include <math.h>

int main()
{
    long heya[10000][10000];
    int n, m;
    int p, q;
    int kaisou[10000];//部屋ごとの数字
    int oya[10000];//親
    int nowserch = 1;
    int count=0;
    scanf("%d", &n);
    scanf("%d", &m);

    for (int i = 1; i <= n;i++){//初期化
        for (int j = 0; j < n;j++){
            heya[i][j] = 0;
            kaisou[i] = 0;
            oya[i] = 0;
        }
    }
    for (int i = 0; i < m;i++){
        scanf("%d %d", &p, &q);
        heya[p][q] = 1;
        heya[q][p] = 1;
    }
    kaisou[1] = 1;//一部屋目は1貝

while(count<m){
    for (int i = 1; i <= n; i++)
    {
        if(kaisou[i]==nowserch){
             for (int j = 1; j <= n; j++)
                {
                if(heya[i][j]==1){//つながりがある
                    count++;
                    if(kaisou[j]==0){//上書き
                        kaisou[j] = kaisou[i] + 1;
                        oya[j] = i;//最後は親の出力
                    }
                }

            }
        
        }
        
    }
    nowserch += 1; //一つ深いところ
}
int check = 0;
for (int i = 2; i <= n; i++)
{
    if (oya[i] == 0)
    {
        check = 1;
        printf("No");
        printf("\n");
    }
}
if(check==0){
    printf("Yes\n");
    for (int i = 2; i <= n; i++)
    {
       
        printf("%d", oya[i]);
        printf("\n");
    }
}

}