Buggy python submission (verdict: Time Limit Exceeded):
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
shortest_path_dict = nx.single_target_shortest_path(G, target=1)

print('Yes')
for i in range(2,room+1):
  print(shortest_path_dict[i][1])


Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
import networkx as nx
room, route_count = map(int,input().split())

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from([list(map(int,input().split())) for _ in range(route_count)])

is_end = False
for i in range(2, room+1):
  if nx.has_path(G,source=i, target=1)==False:
    is_end = True
    break

if is_end:
  print('No')
else:
  print('Yes')
  shortest_path_dict = nx.single_target_shortest_path(G, target=1)
  for i in range(2,room+1):
    print(shortest_path_dict[i][1])


Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
import networkx as nx
room, route_count = map(int,input().split())
G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from([list(map(int,input().split())) for _ in range(route_count)])
if all([nx.has_path(G,source=i, target=1) for i in range(1, room+1)]):
  print('Yes')
  shortest_path_dict = nx.single_target_shortest_path(G, target=1)
  for i in range(2,room+1):
    print(shortest_path_dict[i][1])
else:
  print('No')

Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
shortest_path_dict = nx.single_target_shortest_path(G, target=1)
if len(shortest_path_dict)<room:
  print('No')
else:
  print('Yes')
  for i in range(2,room+1):
    print(shortest_path_dict[i][1])


Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
import networkx as nx
room, route_count = map(int,input().split())

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from([list(map(int,input().split())) for _ in range(route_count)])
shortest_path_dict = nx.shortest_path(G, target=1)
if len(shortest_path_dict)<room:
  print('No')
else:
  print('Yes')
  for i in range(2,room+1):
    print(shortest_path_dict[i][1])


Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
shortest_path_dict = nx.shortest_path(G, target=1)
if len(shortest_path_dict)<room:
  print('No')
else:
  print('Yes')
  for i in range(2,room+1):
    print(shortest_path_dict[i][1])


Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Runtime Error):
import numpy as np
room, route_count = map(int,input().split())
route = np.array([list(map(int,input().split())) for _ in range(route_count)])
 
object_nums = [1]
ans = np.array([0]*(room-1))
 
def mem_ans(ans, object_num, next_nums):
    mask_array = np.zeros(room-1, dtype=bool)
    mask_array[next_nums-2] = True
    ans[(ans==0) & mask_array] = object_num
    return ans
 
for object_num in object_nums:
    object_num_mask = np.any(route==object_num, axis=1)
    object_rows = route[object_num_mask]
    route = route[~object_num_mask]
    next_nums = object_rows[object_rows!=object_num]
    if next_nums is not None:
        ans = mem_ans(ans, object_num, next_nums)
        object_nums.extend(next_nums)
    else:
        break
 
if 0 in set(ans):
  print('No')
else:
  print('Yes')
  for i in ans:
    print(i)

Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
room, route_count = map(int,input().split())
route = np.array([list(map(int,input().split())) for _ in range(route_count)])
 
object_nums = [1]
ans = np.array([0]*(room-1))
 
def mem_ans(ans, object_num, next_nums):
    mask_array = np.zeros(room-1, dtype=bool)
    mask_array[next_nums-2] = True
    ans[(ans==0) & mask_array] = object_num
    return ans
 
for object_num in object_nums:
    object_num_mask = np.any(route==object_num, axis=1)
    object_rows = route[object_num_mask]
    route = route[~object_num_mask]
    next_nums = object_rows[object_rows!=object_num]
    if next_nums is not None:
        ans = mem_ans(ans, object_num, next_nums)
        object_nums.extend(next_nums)
    else:
        break
 
if 0 in set(ans):
  print('No')
else:
  print('Yes')
  for i in ans:
    print(i)

Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
room, route_count = map(int,input().split())
route = np.array([list(map(int,input().split())) for _ in range(route_count)])
 
object_nums = [1]
ans = np.array([0]*(room-1))
 
def mem_ans(ans, object_num, next_nums):
    mask_array = np.zeros(room-1, dtype=bool)
    mask_array[next_nums-2] = True
    ans[(ans==0) & mask_array] = object_num
    return ans
 
for object_num in object_nums:
 
    object_rows = route[np.any(route==object_num, axis=1)]
    route[np.any(route==object_num, axis=1)] = 0
    next_nums = object_rows[object_rows!=object_num]
    if next_nums is not None:
        ans = mem_ans(ans, object_num, next_nums)
        object_nums.extend(next_nums)
    else:
        break
 
if 0 in set(ans):
  print('No')
else:
  print('Yes')
  for i in ans:
    print(i)

Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Runtime Error):
import numpy as np
room, route_count = map(int,input().split())
route = np.array([list(map(int,input().split())) for _ in range(route_count)])
 
object_nums = [1]
ans = np.array([0]*(room-1))
 
def mem_ans(ans, object_num, next_nums):
    mask_array = np.zeros(room-1, dtype=bool)
    mask_array[next_nums-2] = True
    ans[ans=0 & mask_array] = object_num
    return ans
 
for object_num in object_nums:
 
    object_rows = route[np.any(route==object_num, axis=1)]
    route[np.any(route==object_num, axis=1)] = 0
    next_nums = object_rows[object_rows!=object_num]
    if next_nums is not None:
        ans = mem_ans(ans, object_num, next_nums)
        object_nums.extend(next_nums)
    else:
        break
 
if 0 in set(ans):
  print('No')
else:
  print('Yes')
  for i in ans:
    print(i)

Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Runtime Error):
import numpy as np
room, route_count = map(int,input().split())
route = np.array([list(map(int,input().split())) for _ in range(route_count)])
 
object_nums = [1]
ans = np.array([0]*(room-1))
 
def mem_ans(ans, object_num, next_nums):
    next_nums = next_nums - 2
    ans[next_nums-2] = object_num
    return ans
 
for object_num in object_nums:
    object_rows = route[np.any(route==object_num, axis=1)]
    route = route[~np.any(route==object_num, axis=1)]
    next_nums = object_rows[object_rows!=object_num]
    
    if next_nums is not None:
        ans = mem_ans(ans, object_num, next_nums)
        object_nums.extend(next_nums)
    else:
        break
print(ans)
if 0 in set(ans):
  print('No')
else:
  print('Yes')
  for i in ans:
    print(i)

Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
room, route_count = map(int,input().split())
route = np.array([list(map(int,input().split())) for _ in range(route_count)])
 
object_nums = [1]
ans = np.array([0]*(room-1))
 
def mem_ans(ans, object_num, next_nums):
    for n in next_nums:
        if ans[n-2] == 0:
            ans[n-2] = object_num
    return ans
 
for object_num in object_nums:

    object_rows = route[np.any(route==object_num, axis=1)]
    route[np.any(route==object_num, axis=1)] = 0
    next_nums = object_rows[object_rows!=object_num]
    if next_nums is not None:
        ans = mem_ans(ans, object_num, next_nums)
        object_nums.extend(next_nums)
    else:
        break
 
if 0 in set(ans):
  print('No')
else:
  print('Yes')
  for i in ans:
    print(i)

Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
room, route_count = map(int,input().split())
route = np.array([list(map(int,input().split())) for _ in range(route_count)])

object_nums = [1]
ans = np.array([0]*(room-1))

def mem_ans(ans, object_num, next):
    if next is not None:
      for n in next:
        if ans[n-2] == 0:
          ans[n-2] = object_num
    return ans

for object_num in object_nums:
    object_rows = route[np.any(route==object_num, axis=1)]
    route[np.any(route==object_num, axis=1)] = 0
    next = object_rows[object_rows!=object_num]
    ans = mem_ans(ans, object_num, next)
    object_nums.extend(next)

if 0 in set(ans):
  print('No')
else:
  print('Yes')
  for i in ans:
    print(i)

Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
room, route_count = map(int,input().split())
route = np.array([list(map(int,input().split())) for _ in range(route_count)])

object_nums = [1]
ans = [0]*(room-1)

def mem_ans(ans, object_num, next):
    if next is not None:
      for n in next:
        if ans[n-2] == 0:
          ans[n-2] = object_num
    return ans

for object_num in object_nums:
    object_rows = route[np.any(route==object_num, axis=1)]
    route[np.any(route==object_num, axis=1)] = 0
    next = object_rows[object_rows!=object_num]
    ans = mem_ans(ans, object_num, next)
    object_nums.extend(next)

if 0 in set(ans):
  print('No')
else:
  print('Yes')
  for i in ans:
    print(i)

Fixed submission:
import networkx as nx
room, route_count = map(int,input().split())
route = [list(map(int,input().split())) for _ in range(route_count)]

G = nx.Graph()
G.add_nodes_from(range(1,room+1))
G.add_edges_from(route)
pre = nx.predecessor(G, 1)

print('Yes')
for i in range(2,room+1):
  print(pre[i][0])