N, M = map(int,input().split()) 
P = [list(map(int,input().split())) for i in range(M)]
A = [ [0 for __ in range(N)] for _ in range(N)]
for path in P:
    A[path[1]-1][path[0]-1]=1
    A[path[0]-1][path[1]-1]=1
#print(A)
depth_list = [0 for _ in range(N)]
next_generation = set([0])
depth = 0
#old_generation = set()
direction = [0 for _ in range(N)]
used = [0 for _ in range(N)]
while len(next_generation)!=0:
    #print('next_gen',next_generation)
    current = next_generation
    for node in next_generation:
        used[node] = 1
    #[old_generation.add(node) for node in next_generation]
    next_generation = set()
    for index in current:
        depth_list[index]=depth
    for node in current:
        #print('node',node,':',A[node])
        
        #print('old',old_generation)
        for i,neighbor in enumerate(A[node]):
            #print("trm",neighbor)

            if neighbor == 1 and used[i]==0:
                #print("unseen",i)
                next_generation.add(i)
                direction[i]=node+1
    depth+=1
if used.count(1) != N:
    print('No')
else:
    print('Yes')
    for d in direction[1:]:
        print(d)
#print(depth_list)
        