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

#define ll long long
#define ARR_SIZE 210000
#define MOD ((ll)1e9 + 7)

typedef struct __node__ {
    int data;
    struct __node__ *next;
} Node;

int main(){
    int n, m, a[ARR_SIZE] = {}, b[ARR_SIZE] = {};
    scanf("%d %d", &n, &m);
    for(int i=0;i<m;i++) scanf("%d %d", a+i, b+i);
    // end input

    Node* room[ARR_SIZE];
    for(int i=1;i<=n;i++) room[i] = NULL;

    for(int path=0;path<m;path++){
        Node* p0 = calloc(1, sizeof(Node));
        p0->data = a[path];
        p0->next = room[b[path]];
        room[b[path]] = p0;

        Node* p1 = calloc(1, sizeof(Node));
        p1->data = b[path];
        p1->next = room[a[path]];
        room[a[path]] = p1;
    }

    int next_room[ARR_SIZE] = {0,1};
    int child_room[ARR_SIZE] = {1};
    int child_room0[ARR_SIZE] = {};
    int num_children = 1;
    int num_children0 = 0;

    if(room[1]==NULL){
        printf("No\n");
        return 0;
    }
    
    while(num_children>0){
        for(int i=0;i<num_children;i++){
            int parent_room = child_room[i];

            Node* ptr = room[parent_room];
            while(ptr!=NULL){
                int data = ptr->data;
                if(next_room[data]>0){
                    ptr = ptr->next;
                    continue;
                }
                next_room[data] = parent_room;
                child_room0[num_children0] = data;
                num_children0 += 1;
                ptr = ptr->next;
            }
        }

        num_children = num_children0;
        for(int j=0;j<num_children;j++){
            child_room[j] = child_room0[j];
        }
        num_children0 = 0;
    }

    int count = 0;
    for(int r=2;r<=n;r++){
        if(next_room[r]==0){
            printf("No\n");
            return 0;
        }
    }
    
    
    printf("Yes\n");
    for(int r=2;r<=n;r++){
        printf("%d\n", next_room[r]);
    }


    return 0;
}


