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

int N, M;

void mark(int *room, int *A, int *B, int id)
{
    for (int c = 0; c < M; ++c)
    {
        if (A[c] == id && room[B[c]] == 0)
        {
            room[B[c]] = -id;
        }
        else if (B[c] == id && room[A[c]] == 0)
        {
            room[A[c]] = -id;
        }
    }
}

void debug(int *room)
{
    printf("debug start\n");
    for (int c = 1; c <= N; ++c)
    {
        printf("%d\n", room[c]);
    }
    printf("debug end\n");
}

int main(void)
{
    int *A, *B, *room, *horizon;
    int check;
    scanf("%d %d", &N, &M);
    A = (int *)malloc(sizeof(int) * M);
    B = (int *)malloc(sizeof(int) * M);
    room = (int *)malloc(sizeof(int) * (N + 1));
    horizon = (int *)malloc(sizeof(int) * (N + 1));
    //1からのindex
    for (int c = 0; c < M; ++c)
    {
        scanf("%d %d", A + c, B + c);
    }
    horizon[1] = 1;
    room[1] = 1;
    for (int c = 2; c <= N; ++c)
    {
        room[c] = 0;
        horizon[c] = 0;
    }
    check = 1;
    while (check)
    {
        check = 0;
        for (int c = 1; c <= N; ++c)
        {
            if (horizon[c] == 1)
            {
                mark(room, A, B, c);
            }
            horizon[c] = 0;
        }
        for (int c = 1; c <= N; ++c)
        {
            if (room[c] < 0)
            {
                horizon[c] = 1;
                room[c] *= -1;
                check = 1;
            }
        }
    }
    for (int c = 2; c <= N; ++c)
    {
        if (room[c] == 0)
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes\n");
    for (int c = 2; c <= N; ++c)
    {
        printf("%d\n", room[c]);
    }
    free(A);
    free(B);
    free(room);
    return 0;
}