output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: # この解答を自分で写経してみる
  N, M = map(int, input().split())
  AB = [map(int, input().split()) for _ in range(M)]
  # map関数を格納したリストを作る
  # この_表記で繰り返すという文化に慣れよう
  
  links = [[] for _ in range(N + 1)]
  # 移動先を出力する
  # リストの入れ子にしたかったら、最初から入れ子として定義しないといけない
  # 何か + for _ in range(M)　で、何かをM回繰り返す
  for a, b in AB:
      # map関数それぞれに対して、値を抽出する
      links[a].append(b)
      links[b].append(a)
  
  from collections import deque
  
  result = [-1] * (N + 1)
  # これで[-1,-1,,,]のリストは作れる
  # 各部屋ごとの出力先
  
  q = deque([1])
  # 始点の定義
  while len(q) > 0:
      i = q.popleft()
      for j in links[i]:
          if result[j] == -1:
              result[j] = i
              # 新しいものをどんどん加えていくことで、層がどんどん深くなっていく
              q.append(j)
  print("yes")
  print("\n".join(str(i) for i in result[2:]))
  
problem_description: Statement
  
  The cat Snuke wants to play a popular Japanese game called ÅtCoder, so Iroha
  has decided to teach him Japanese.
  
  When counting pencils in Japanese, the counter word "本" follows the number.
  The pronunciation of this word varies depending on the number. Specifically,
  the pronunciation of "本" in the phrase "N 本" for a positive integer N not
  exceeding 999 is as follows:
  
    * `hon` when the digit in the one's place of N is 2, 4, 5, 7, or 9;
    * `pon` when the digit in the one's place of N is 0, 1, 6 or 8;
    * `bon` when the digit in the one's place of N is 3.
  
  Given N, print the pronunciation of "本" in the phrase "N 本".
samples: [{"input": "16", "output": "pon\n    \n\nThe digit in the one's place of 16 is 6, so the \"\u672c\" in \"16 \u672c\" is pronounced\n`pon`.\n\n* * *"}, {"input": "2", "output": "hon\n    \n\n* * *"}, {"input": "183", "output": "bon"}]