#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define INF 2000000000
#define PI 3.14159265359
#define ull unsigned long long

int saiki(int *a,int *b,int m,int n,int *queue,int *check,int count,int len){
    int i;
    for (i=1; i<=m; i++) {
        if (a[i]==queue[len]) {
            queue[len+1]=b[i];len++;
            check[b[i]]=count;
            a[i]=0;b[i]=0;
            saiki(a,b,m,n,queue,check,count+1,len);
        }else if (b[i]==queue[len]){
            queue[len+1]=a[i];len++;
            check[a[i]]=count;
            a[i]=0;b[i]=0;
            saiki(a,b,m,n,queue,check,count+1,len);
        }
    }
    return 0;
}

int main(){
    int i,n,m,a[200002]={},b[200002]={},check[200002]={},queue[200002]={};
    scanf("%d%d",&n,&m);
    for (i=1; i<=m; i++){
        scanf("%d%d",&a[i],&b[i]);
        check[a[i]]++;check[b[i]]++;
    }
    for (i=1; i<=n; i++) {
        if (check[i]==0) {
            printf("No");
            return 0;
        }
    }
    for (i=0; i<=m; i++) check[i]=0;
    printf("Yes\n");
    queue[0]=1;
    saiki(a,b,m,n,queue,check,1,0);
    for (i=2; i<=n; i++) {
        printf("%d\n",check[i]);
    }
    return 0;
}

