# -*- coding: utf-8 -*-

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



dict_path = {i+1: [] for i in range(N)}



for _ in range(M):

  A,B = list(map(int, input().split()))

  dict_path[A].append(B)

  dict_path[B].append(A)



list_bfs = [1]

list_flg = [0 for _ in range(N+1)]

list_flg[1] = 1



while len(list_bfs)>0:

  list_tmp = []

  for i in list_bfs:

    for j in dict_path[i]:

      if list_flg[j]==0:

        list_tmp.append(j)

        list_flg[j] = i

  list_bfs = list_tmp



print('Yes')

for i in list_flg[2:]:

  print(i)
# -*- coding: utf-8 -*-

import sys



N, M, *AB = list(map(int, sys.stdin.buffer.read().split()))



dict_path = {i+1: [] for i in range(N)}



for i in range(M):

  A,B = AB[2*i:2*i+2]

  dict_path[A].append(B)

  dict_path[B].append(A)



list_bfs = [1]

list_flg = [0 for _ in range(N+1)]

list_flg[1] = 1



while len(list_bfs)>0:

  list_tmp = []

  for i in list_bfs:

    for j in dict_path[i]:

      if list_flg[j]==0:

        list_tmp.append(j)

        list_flg[j] = i

  list_bfs = list_tmp



print('Yes')

for i in list_flg[2:]:

  print(i)
# -*- coding: utf-8 -*-
N, M = list(map(int, input().split()))
dict_path = {i + 1: [] for i in range(N)}
for _ in range(M):
    A, B = list(map(int, input().split()))
    dict_path[A].append(B)
    dict_path[B].append(A)
list_bfs = [1]
list_flg = [0 for _ in range(N + 1)]
list_flg[1] = 1
while len(list_bfs) > 0:
    list_tmp = []
    for i in list_bfs:
        for j in dict_path[i]:
            if list_flg[j] == 0:
                list_tmp.append(j)
                list_flg[j] = i
    list_bfs = list_tmp
print("Yes")
for i in list_flg[2:]:
    print(i)

# -*- coding: utf-8 -*-
import sys

N, M, *AB = list(map(int, sys.stdin.buffer.read().split()))
dict_path = {i + 1: [] for i in range(N)}
for i in range(M):
    A, B = AB[2 * i : 2 * i + 2]
    dict_path[A].append(B)
    dict_path[B].append(A)
list_bfs = [1]
list_flg = [0 for _ in range(N + 1)]
list_flg[1] = 1
while len(list_bfs) > 0:
    list_tmp = []
    for i in list_bfs:
        for j in dict_path[i]:
            if list_flg[j] == 0:
                list_tmp.append(j)
                list_flg[j] = i
    list_bfs = list_tmp
print("Yes")
for i in list_flg[2:]:
    print(i)

-N, M = list(map(int, input().split())) +import sys + +N, M, *AB = list(map(int, sys.stdin.buffer.read().split())) -for _ in range(M): -    A, B = list(map(int, input().split())) +for i in range(M): +    A, B = AB[2 * i : 2 * i + 2]