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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]

struct slist
{
    int index;
    struct slist *next;
};

typedef struct slist list;


list *putV(list *v, int go){
    list *u = (list *)malloc(sizeof(int));
    u->index = go;
    u->next = v;
    return u;
}

int getV(list **v){
    if(*v == NULL) return -1;
    int a = (*v)->index;
    list *u = *v;
    (*v) = (*v)->next;
    
    // free(u);
    return a;
}

int isNull(list *v){return v == NULL;}

list *V[100001];
int ans[1000001];
int che[1000001];
int n , m;
int checkn;

void sol(list *s, int d){
    int a, b;
    list *next_s=NULL;
  if(checkn == n) return;

    while (!isNull(s))
    {
        a = getV(&s);
        while(!isNull(V[a])){
            b = getV(&V[a]);
            if(che[b] == 0){
                ans[b] = d;
                next_s = putV(next_s, b);
                che[b]++;
              checkn++;
            }
        }
    }

    return sol(next_s, d+1);
}

int main(){
    int a, b;
    list first;

    for (int i = 0; i < 100001; i++)
    {
        V[i] = NULL;
    }

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

    first.index = 1;
    first.next = NULL;
    sol(&first, 1);

    printf("Yes\n");

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