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

#define FALSE 0
#define TRUE  (!FALSE)
#define MAXSTOCK 500000
#define AMAX 200001

struct CELL_t {
    struct CELL_t *next;
    int d;
    int used;
};
typedef struct CELL_t CELL;

CELL stock[MAXSTOCK];
CELL *varray[AMAX];

CELL *newCell()
{
    static int last = 0;
    CELL *rv = NULL;

    for( int i=0; i<MAXSTOCK; i++ ) {

        if( ! stock[last].used ) {
            stock[last].used = TRUE;
            rv = &stock[last];
            last = (last + 1) % MAXSTOCK;
            break;
        } else {
            last = (last + 1) % MAXSTOCK;
        }
    }

    return( rv );
}

void addCell( int n, int val )
{
    if( n >= AMAX ) {
        puts( "In addCell out of range." );
        exit( -1 );
    }

    CELL *c = newCell();
    if( c == NULL ) {
        printf( "No new stock available.\n" );
        exit( -1 );
    }

    c->d = val;

    if( varray[n] == NULL ) {
        varray[n] = c;
        c->next = NULL;
    } else {
        c->next = varray[n];
        varray[n] = c;
    }
}

void printArray()
{
    for( int i=0; i<AMAX; i++ ) {
        if( varray[i] ) {
            printf( "%d:", i );

            CELL *next = varray[i];
            while( next ) {
                printf( " %d", next->d );
                next = next->next;
            }
            printf( "\n" );
        }
    }
}

int main( int argc, char *argv )
{
    int n, m;
    int a, b;
    int f;
    int depth[200001];
    int ans[200001];

    scanf( "%d %d", &n, &m );
    for( int i=0; i<m; i++ ) {
        scanf( "%d %d", &a, &b );
        addCell( a, b );
        addCell( b, a );
    }

//    printArray();

    for( int i=0; i<=n; i++ ) depth[i] = -1;
    depth[1] = 0;

    for( int d=0; d<n; d++ ) {
        f = FALSE;
        for( int i=1; i<=n; i++ ) {
            if( depth[i] == d ) {
                CELL *c = varray[i];
                while( c ) {
                    if( depth[c->d] == -1 ) {
                        depth[c->d] = d + 1;
                        ans[c->d] = i;
                        f = TRUE;
                    }
                    c = c->next;
                }
            }
        }
        if( ! f ) break;
    }

//for( int i=1; i<=n; i++ ) printf( "%d %d\n", i, depth[i] );

    for( int i=1; i<=n; i++ ) {
        if( depth[i] == -1 ) {
            puts( "No" );
            exit( 0 );
        }
    }

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