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

#define ll long long
#define ARR_SIZE 210000
#define MOD ((ll)1e9 + 7)


int main(){
    int n, m, a[ARR_SIZE] = {}, b[ARR_SIZE] = {};
    scanf("%d %d", &n, &m);
    for(int i=0;i<m;i++) scanf("%d %d", a+i, b+i);
    // end input

    int depth[ARR_SIZE] = {}, next[ARR_SIZE] = {};

    depth[1] = 1;
    next[1] = 1;
    for(int d=1;d<=n;d++){
        for(int r=1;r<=n;r++){
            if(depth[r]==d){
                //printf("room: %d, depth: %d\n", r, d);
                for(int i=0;i<m;i++){
                    if(b[i]==r){
                        //printf("00room: %d, path: %d %d\n", r, a[i], b[i]);
                        b[i] = a[i];
                        a[i] = r;
                    }
                    
                    if(a[i]==r){
                        //printf("room: %d, path: %d %d\n", r, a[i], b[i]);
                        if(depth[b[i]]>0) continue;
                        depth[b[i]] = depth[r] + 1;
                        next[b[i]] = r;
                        a[i] = b[i] = 0;
                    }
                }
            }
        }
    }

    //printf("--------------------\n");
    for(int i=0;i<m;i++){
        //printf("%d %d\n", a[i], b[i]);
    }
    //printf("--------------------\n");
    for(int i=1;i<=n;i++){
        //printf("%d...   next: %d   depth: %d\n", i, next[i], depth[i]);
    }

    int count = 0;
    for(int r=1;r<=n;r++){
        if(next[r]>0){
            count++;
        }
    }

    if(count==n){
        printf("yes\n");
        for(int r=2;r<=n;r++){
            printf("%d\n", next[r]);
        }
    }else{
        printf("no\n");
    }

    return 0;
}


