#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define SIZE 100000
#define rep(i, N) for (i = 0; i < N; i++) //制御変数iを用いてN回転
#define array(N, t) (t*)calloc(N, sizeof(t)) //t型N要素の1次元配列を動的確保後0クリア(freeを忘れずに)
#define zero(a); {int iter; rep(iter, sizeof(a)/sizeof((a)[0])) (a)[iter]=0;} //1次元配列aのゼロ初期化?
typedef long long ll;
void print_log(); //とりあえず文字を出力してどこまで実行できているか確認(for debug)
void printa_int(int *a, int size); //int型の1次元配列aを出力(for debug)
typedef struct node {
    int data;
    struct node *next;
} Node;
void add_node(Node *head, int data) {
    if (head->data == -1) {
        head->data = data;
        return;
    }
    Node* t = head;
    head = (Node*)malloc(sizeof(Node*));
    head->data = data;
    head->next = t;
}
void free_node(Node* head) {
    Node *prev = NULL, *t = head;
    while (t) {
        prev = t;
        t = t->next;
        free(prev);
    }
}
int q[SIZE]; //queue
int q_head = 0, q_tail = 0;
int queue_empty() {
    return q_head == q_tail;
}
int queue_full() {
    return (q_head - 1) % SIZE == q_tail % SIZE;
}
void enqueue(int data) {
    if (queue_full()) {
        printf("full!\n");
        return;
    }
    q[q_tail++] = data;
    q_tail %= SIZE;
}
int dequeue() {
    if (queue_empty()) {
        printf("empty!\n");
        return -444444;
    }
    int data = q[q_head++];
    q_head %= SIZE;
    return data;
}

int main() {
    int i, N, M, A, B;
    int *ms, prev;
    Node *room, *t;
    scanf("%d %d", &N, &M);
    room = array(N, Node);
    ms = array(N, int);
    rep(i, N) {
        room[i].data = -1;
        ms[i] = -1;
    }
    rep(i, M) {
        scanf("%d %d", &A, &B);
        add_node(&room[A - 1], B - 1);
        add_node(&room[B - 1], A - 1);
    }
    ms[0] = 0;
    prev = 0;
    for (t = room; t; t = t->next) {
        enqueue(t->data);
        ms[t->data] = prev;
    }
    while (!queue_empty()) {
        prev = dequeue();
        for (t = room + prev; t; t = t->next) {
            if (ms[t->data] != -1) continue;
            enqueue(t->data);
            ms[t->data] = prev;
        }
    }
    rep(i, N) {
        if (!i) printf("Yes\n");
        else printf("%d\n", ms[i] + 1);
    }
    free(room);
    free(ms);
    return 0;
}

void print_log() {
    printf("===finish!===\n");
}

void printa_int(int *a, int size) {
    int i;
    printf("[");
    for (i = 0; i < size; i++)
        printf("%d, ", a[i]);
    printf("]\n");
}