
from collections import deque

def parse():
  N, M = map(int, input().split(" "))

  rooms = [[] for n in range(N)]
  for m in range(M):
    a, b = map(int, input().split(" "))
    rooms[a - 1].append(b - 1)
    rooms[b - 1].append(a - 1)
  
  return N, M, rooms

def main():
  N, M, rooms = parse()
  # print(rooms)

  # 探索する部屋番号をqに入れる
  q = deque([])
  q.append(0)

  # 各部屋の道しるべを入れる変数
  guides = [None for n in range(N)]
  guides[0] = 0
  while len(q) > 0:
    room_num = q.popleft()
    # print("room_num:", room_num)

    # 次に探索する部屋は，今の部屋を道しるべに指す
    for next_room_num in rooms[room_num]:
      # print("guides[next_room_num]:", guides[next_room_num])
      if guides[next_room_num] == None:
        q.append(next_room_num)
        # print(next_room_num)
      
        guides[next_room_num] = room_num
        # if next_room_num != room_num:

      
    # print("q:", q)
    # print("guides:", guides)
    # input()
  
  for guide in guides[1:]:
    if guide == None:
      print("No")
      exit(0)
  print("Yes")
  for guide in guides[1:]:
    print(guide + 1)

if __name__ == "__main__":
  main()