#include <stdio.h>

int N, M;
int A[200000], B[200000];
int mark[100000];
int dist[100000];

int goRoad(int np, int nd) {
    for(int i = 0; i < M; i++) {
        if(A[i] == np) {
            if(dist[B[i]] > nd + 1) {
                dist[B[i]] = nd + 1;
                mark[B[i]] = np;
                goRoad(B[i], nd + 1);
            }
        }
        if(B[i] == np) {
            if(dist[A[i]] > nd + 1) {
                dist[A[i]] = nd + 1;
                mark[A[i]] = np;
                goRoad(A[i], nd + 1);
            }
        }
    }

    return 0;
}

int main(void) {
    int np, nd;
    int tmp;

    scanf("%d %d", &N, &M);
    for(int i = 0; i < N; i++) {
        mark[i] = -1;
        dist[i] = 200001;
    }
    for(int i = 0; i < M; i++) {
        scanf("%d %d", &A[i], &B[i]);
        A[i]--;
        B[i]--;
        if(A[i] > B[i]) {
            tmp = A[i];
            A[i] = B[i];
            B[i] = tmp;
        }
    }

    for(int i = 0; i < M; i++) {
        for(int j = i + 1; j < M; j++) {
            if(A[i] > A[j]) {
                tmp = A[i];
                A[i] = A[j];
                A[j] = tmp;
                tmp = B[i];
                B[i] = B[j];
                B[j] = tmp;
            }
            else if((A[i] == A[j]) && (B[i] > B[j])) {
                tmp = B[i];
                B[i] = B[j];
                B[j] = tmp;
            }
        }
    }

    goRoad(0, 0);

    for(int i = 0; i < N; i++) {
        if(mark[i] == -1) {
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");
    for(int i = 1; i < N; i++) {
        printf("%d\n", mark[i] + 1);
    }

    return 0;
}
