#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define BUFF_SIZE (int)(2e5 + 1)

typedef struct {
    int writeidx;
    int readidx;
    int count;
    int buff[BUFF_SIZE];
} FIFO;

void fifo_init(FIFO *fifo)
{
    fifo->writeidx = 0;
    fifo->readidx = 0;
    fifo->count = 0;
}

void fifo_enqueue(FIFO *fifo, int *v)
{
    int i;

    if (v == NULL)
        return;

    if (fifo->count < BUFF_SIZE) {
        i = fifo->writeidx;
        fifo->count++;
        fifo->buff[i] = *v;
        fifo->writeidx = (i + 1) % BUFF_SIZE;
    }
}

bool fifo_dequeue(FIFO *fifo, int *r)
{
    int i;

    if (r == NULL)
        return 1;

    if (fifo->count == 0)
        return 1;

    i = fifo->readidx;
    *r = fifo->buff[i];
    fifo->count--;
    fifo->readidx = (i + 1) % BUFF_SIZE;

    return 0;
}

int main(void)
{
	
	  int N, M, A, B;
    int pass[(int)1e5 + 1][(int)1e5 + 1];
    int ans[(int)2e5 + 1] = {};
    FIFO fifo;
    int cave;

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

    fifo_init(&fifo);
    cave = 1;
    fifo_enqueue(&fifo, &cave);

    while (fifo_dequeue(&fifo, &cave) == 0) {
        for (int i = 0; pass[cave][i] != 0; i++) {
            if (ans[pass[cave][i]] == 0) {
                ans[pass[cave][i]] = cave;
                fifo_enqueue(&fifo, &pass[cave][i]);
            }
        }
    }

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

    return 0;
}
