import numpy as np
a = list(map(int,input().split()))
k = []
for i in range(0,a[0]) :
    k.append([])
for i in range(0,a[1]) :
    b = list(map(int,input().split()))
    k[b[0]-1].append(b[1])
    k[b[1]-1].append(b[0])

room = []
dkt = []
for i in range(0,a[0]) :
    if i == 0 :
        room.append(0)
    else :
        room.append(-1)
dkt.append(room)
room = []
for i in range(0,a[0]) :
    room.append(-1)
for i in range(0,a[0]) :
    dkt.append(room)
dkt = np.array(dkt).tolist()

for i in range(1,a[0]+1) :
    for j in range(0,a[0]) :
        if dkt[i-1][j] < 0 :
            continue
        dkt[i][j] = dkt[i-1][j]
        for m in k[j] :
            if dkt[i][m-1] < 0 :
                dkt[i][m-1] = dkt[i-1][j] + 1
            else :
                dkt[i][m-1] = min(dkt[i-1][j] + 1,dkt[i-1][m-1])

ans = dkt[len(dkt)-1][1:]
if min(ans) < 0 :
    print("No")
else :
    print("Yes")
    for i in ans :
        print(i)