import math
n, k = map(int,input().split())
g={}
for i in range(n):
    g[i]=[]
for i in range(k):
    a,b= map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
ans = [-1] * n
queue = [0]
visited = [False] * n
 

while queue:
    x = queue.pop(0)
    for n in g[x]:
        if visited[n] == False: 
            queue.append(n)
            if ans[n] == -1: 
                ans[n] = x
                visited[n] = True
 
if -1 in ans[1:]:
    print('No')
else:
    print('Yes')
    for a in ans[1:]:
        print(a+1)