nm = list(map(int,input().split()))
n = nm[0]
m = nm[1]
a = []
b = []
for i in range(0, m):
    ab = list(map(int,input().split()))
    a.append(ab[0])
    b.append(ab[1])
signs = [0]*(n+1)
signs[1]=-1
now = [1]
nexx = []
while True:
    for i in now:
        for j in range(0,m):
            if a[j] == i:
                if signs[b[j]] == 0:
                    signs[b[j]] = i
                    nexx.append(b[j])
            elif b[j] == i:
                if signs[a[j]] == 0:
                    signs[a[j]] = i
                    print("signs=",signs)
                    nexx.append(a[j])
    now=nexx.copy()
    if len(nexx)==0:
        break
    nexx = []
flag = 0
for i in range(2, n+1):
    if signs[i]==0:
        print("No")
        flag = 1
        break
if flag == 0:
    print("Yes")
    for k in range(2,n+1):
        print(signs[k])

