#include <stdio.h>

int main(){
    int i = 0, j = 0;
    int N, M;
    int A[20000] = {0};
    int B[20000] = {0};
    scanf("%d%d", &N, &M);
    for (i = 0; i < M;i++){
        scanf("%d%d", &A[i], &B[i]);
    }

    int m[20000] = {0};
    int list[20000] = {1,0};
    int next_list[20000] = {0};
    int cnt = 0;
    int lis = 0;

    while(cnt<N){
        int i = 0;
        int k = 0;
        while(next_list[k]>0){
            list[k] = next_list[k];
            k++;
        }
            while (list[i] > 0)
            {
                lis = list[i];
                for (j = 0; j < M; j++)
                {
                    if (A[j] == lis && m[B[j] - 1] == 0)
                    {
                        m[B[j] - 1] = A[j];
                        next_list[i] = B[j];
                        cnt++;
                    }
                    if (B[j] == lis && m[A[j] - 1] == 0)
                    {
                        m[A[j] - 1] = B[j];
                        next_list[i] = A[j];
                        cnt++;
                    }
                }
                i++;
            }
        
    }
    puts("Yes");
    i = 1;
    while(m[i]>0){
        printf("%d\n", m[i]);
        i++;
    }
    return 0;
}