from collections import deque
n,m = list(map(int,input().split()))
e = [[] for _ in range(m+1)]
for i in range(m):
    a,b = list(map(int,input().split()))
    e[a].append(b)
    e[b].append(a)
q = deque()
q.append(1)
s = [float('inf') for _ in range(n+1)]
t = [-1 for _ in range(n+1)]
s[1] = 0
while len(q):
    node = q.pop()
    step = s[node]+1
    for i in range(len(e[node])):
        nex = e[node][i]
        if s[nex] > step:
            q.append(nex)
            s[nex] = step
            t[nex] = node
# print(s,t,e)
print("Yes")
for i in range(2,n+1):
    print(t[i])