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

typedef struct LinkedList {
    int val;
    struct LinkedList *next;
} LinkedList;

LinkedList *create_list(int val) {
    LinkedList *list = malloc(sizeof(LinkedList));
    list->val = val;
    list->next = NULL;
    return list;
}

void show(LinkedList *list) {
    while(list != NULL) {
        printf("%d, ", list->val);
        list = list->next;
    }
    printf("\n");
}

LinkedList *append(LinkedList *list, int val) {
    if (list == NULL)
        return create_list(val);

    LinkedList *start = list;
    while (list->next != NULL)
        list = list->next;
    list->next = create_list(val);
    return start;
}

typedef struct Queue {
    struct LinkedList *head;
} Queue;

Queue *create_queue() {
    Queue *queue = malloc(sizeof(Queue));
    queue->head = NULL;
    return queue;
}

void push(Queue *queue, int val) {
    if (queue->head == NULL) {
        queue->head = create_list(val);
    } else {
        append(queue->head, val);
    }
}

int pop(Queue *queue) {
    if (queue->head == NULL)
        return 0;

    LinkedList *head = queue->head;
    int result = head->val;
    queue->head = head->next;
    free(head);
    return result;
}

void write_path(LinkedList **nodes, int *DP) {
    Queue *queue = create_queue();
    push(queue, 1);
    int current_room;
    while((current_room = pop(queue)) != 0) {
        //printf("current_room: %d\n", current_room);
        LinkedList *next_rooms = nodes[current_room];
        while(next_rooms != NULL) {
            if (DP[next_rooms->val] == 0) {
                //printf("-> next_room: %d\n", next_rooms->val);
                DP[next_rooms->val] = current_room;
                push(queue, next_rooms->val);
            }
            next_rooms = next_rooms->next;
        }
    }
}

int main () {
    int N;
    int M;
    scanf("%d", &N);
    scanf("%d", &M);

    LinkedList **nodes = calloc(N + 1, sizeof(LinkedList));
    int i = 1;
    while(i++ <= M) {
        int A;
        int B;
        scanf("%d", &A);
        scanf("%d", &B);
        nodes[A] = append(nodes[A], B);
        nodes[B] = append(nodes[B], A);
    }
    //show(nodes[1]);
    //show(nodes[2]);
    //show(nodes[3]);
    //show(nodes[4]);
    int *DP = calloc(N+1, sizeof(int));
    DP[1] = 0;
    write_path(nodes, DP);

    int result[N - 1];
    for (int i = 2; i <= N; i++) {
        if (DP[i] == 0) {
            printf("No\n");
            return 0;
        }
        result[i-2] = DP[i];
    }
    printf("Yes\n");
    for (int i = 0; i < (N - 1); i++) {
        printf("%d\n", result[i]);
    }

    return 0;
}
