N, M = list(map(int, input().split()))
paths = [list(map(int, input().split())) for _ in range(M)]

result = []
passed_room = [1]
depth = 1

while paths and depth<N:
  tmp_passed = passed_room.copy()
  
  for i, path in enumerate(paths):
   
    if path[0] in passed_room:
      if path[1] in passed_room:
        del paths[i]
        continue
      result.append((path[1], path[0]))
      tmp_passed.append(path[1])
      del paths[i]
      continue
    
    if path[1] in passed_room:
      if path[0] in passed_room:
        del paths[i]
      result.append((path[0], path[1]))
      tmp_passed.append(path[0])
      del paths[i]
      continue
  depth += 1
  passed_room  = passed_room + tmp_passed
  if len(tmp_passed) == 0:
    print('No')
    exit()
  
    
result = sorted(result)
print('Yes')
for i, j in result:
  print(j)