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: # coding: utf-8
  
  
  def dijkstra(costs, s, t, INF=10**10):
      """
      2020/04/11
      https://atcoder.jp/contests/abc079/tasks/abc079_d
  
      Parameters
      ----------
      costs: list of list of int
      e.g. [[-1,  4,  1, -1],
            [ 4, -1,  5, -1],
            [ 1,  5, -1,  6],
            [-1, -1,  6, -1]]
      """
  
      costs = [[c if c >= 0 else INF for c in row] for row in costs]
      n_node = len(costs)
  
      # adjacents = {}
      # for i in range(n_node):
      #     adjacents[i] = set([j for j in range(n_node) if 0 < costs[i][j] < INF])
  
      dist_from_s = [INF] * n_node
      dist_from_s[s] = 0
      checked = []  # nodes having fixed shortest distance
  
      while True:
          print(dist_from_s)
          # not checked nodes (not fixed nodes)
          nodes = [node for node in range(n_node) if node not in checked]
  
          # find the node having minimum cost from s
          # initialize
          shortest_node, shortest_dist = nodes[0], dist_from_s[nodes[0]]
  
          for node in nodes:
              if dist_from_s[node] < shortest_dist:
                  shortest_node, shortest_dist = node, dist_from_s[node]
  
          if shortest_node == t:
              return dist_from_s[t]
  
          checked.append(shortest_node)  # fix
  
          # not checked nodes (not fixed nodes)
          nodes = [node for node in range(n_node) if node not in checked]
  
          # update
          for node in nodes:
              dist_from_s[node] = min(
                  dist_from_s[shortest_node] + costs[shortest_node][node],
                  dist_from_s[node],
              )
  
  
  def main():
      N, M = map(int, input().split())
      A = [None] * M
      B = [None] * M
      for i in range(M):
          A[i], B[i] = map(int, input().split())
          A[i] -= 1
          B[i] -= 1
  
      edge_info = {i: [] for i in range(N)}
      for i in range(M):
          edge_info[A[i]].append(B[i])
          edge_info[B[i]].append(A[i])
  
      # dists = [None] * N
      # dists[0] = 0
      prenodes = [None] * N
      prenodes[0] = 0
      queue = [0]
      queue_size = 1
      queue_idx = 0
      while True:
          # 貪欲に
          if queue_idx == queue_size:
              break
  
          x = queue[queue_idx]
          queue_idx += 1
          nexts = [y for y in edge_info[x] if prenodes[y] is None]
          for node in nexts:
              prenodes[node] = x
              queue.append(node)
              queue_size += 1
  
      print("Yes")
      for i in range(1, N):
          print(prenodes[i] + 1)
  
  
  main()
  # print(main())
  
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."}]