output_description: If there is no way to place signposts satisfying the objective, print `No`.
  
  Otherwise, print N lines. The first line should contain `Yes`, and the i-th
  line (2 \leq i \leq N) should contain the integer representing the room
  indicated by the signpost in Room i.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
      A_1 B_1
      :
      A_M B_M
attempt: import sys
  
  sys.setrecursionlimit(10**8)
  
  
  def ii():
      return int(sys.stdin.readline())
  
  
  def mi():
      return map(int, sys.stdin.readline().split())
  
  
  def li():
      return list(map(int, sys.stdin.readline().split()))
  
  
  def li2(N):
      return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
  
  
  def dp2(ini, i, j):
      return [[ini] * i for i2 in range(j)]
  
  
  def dp3(ini, i, j, k):
      return [[[ini] * i for i2 in range(j)] for i3 in range(k)]
  
  
  # import bisect #bisect.bisect_left(B, a)
  # from collections import defaultdict #d = defaultdict(int) d[key] += value
  # from collections import Counter # a = Counter(A).most_common()
  # from itertools import accumulate #list(accumulate(A))
  
  from collections import deque
  
  N, M = mi()
  # U = UnionFind(N)
  rel = [[] for _ in range(N)]
  
  mark = [-1] * N
  flag = [0] * N
  mark[0] = 0
  l = deque([0])
  """
  def dfs(s):
      print(mark)
      if rel[s]:
          for num in rel[s]:
              if mark[num] == -1:
                  mark[num] = s
          for num in rel[s]:
              if rel[num]:
                  dfs(num)   
  """
  for i in range(M):
      s, t = mi()
      s -= 1
      t -= 1
      rel[s].append(t)
      rel[t].append(s)
  
  # dfs(0)
  flag[0] = 1
  while l != deque([]):
      a = l.popleft()
      for num in rel[a]:
          if not flag[num]:
              mark[num] = a
              flag[num] = 1
              l.append(num)
  
  if sum(flag) != N:
      print("No")
      exit()
  print("Yes")
  for i in range(1, N):
      print(mark[i] + 1)
  
problem_description: Statement
  
  There is a cave.
  
  The cave has N rooms and M passages. The rooms are numbered 1 to N, and the
  passages are numbered 1 to M. Passage i connects Room A_i and Room B_i
  bidirectionally. One can travel between any two rooms by traversing passages.
  Room 1 is a special room with an entrance from the outside.
  
  It is dark in the cave, so we have decided to place a signpost in each room
  except Room 1. The signpost in each room will point to one of the rooms
  directly connected to that room with a passage.
  
  Since it is dangerous in the cave, our objective is to satisfy the condition
  below for each room except Room 1.
  
    * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.
  
  Determine whether there is a way to place signposts satisfying our objective,
  and print one such way if it exists.
samples: [{"input": "4 4\n    1 2\n    2 3\n    3 4\n    4 2", "output": "Yes\n    1\n    2\n    2\n    \n\nIf we place the signposts as described in the sample output, the following\nhappens:\n\n  * Starting in Room 2, you will reach Room 1 after traversing one passage: (2) \\to 1. This is the minimum number of passages possible.\n  * Starting in Room 3, you will reach Room 1 after traversing two passages: (3) \\to 2 \\to 1. This is the minimum number of passages possible.\n  * Starting in Room 4, you will reach Room 1 after traversing two passages: (4) \\to 2 \\to 1. This is the minimum number of passages possible.\n\nThus, the objective is satisfied.\n\n* * *"}, {"input": "6 9\n    3 4\n    6 1\n    2 4\n    5 3\n    4 6\n    1 5\n    6 2\n    4 5\n    5 6", "output": "Yes\n    6\n    5\n    5\n    1\n    1\n    \n\nIf there are multiple solutions, any of them will be accepted."}]