N, M = map(int, input().split())

ans = [-1 for i in range(N-1)]
path = [[] for i in range(N)]

for i in range(M):
  A, B = map(int, input().split())
  path[A-1].append(B)
  path[B-1].append(A)
nows = [1]
COUNTER = 0
while len(nows)>0 :
  buf = []
  for now in nows:
    for p in path[now-1]:
      if ans[p-2]==-1:
        ans[p-2]=now
        buf.append(p)
        #print(COUNTER)
        COUNTER+=1
  nows = buf
  
print("Yes")
for i in ans:
  print(i)
