Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import deque

ab = np.array([], int)
n,m = map(int, input().split())

for i in range(m):
    ab = np.append(ab, list(map(int, input().split())), axis=0)

ab = ab.reshape(m,2)

path = [[] for _ in range(n)]


for i in range(m):
    path[ab[i][0]-1].append(ab[i][1])
    path[ab[i][1]-1].append(ab[i][0])
    
d = deque([0])
dis = np.ones(n, int) * -1
dis[0] = 0

while d:
    hop = d.popleft()
    for i in path[hop]:
        if dis[i-1] == -1:
            d.append(i-1)
            dis[i-1] = hop+1
            
if np.count_nonzero(dis)+1 != n:
    print('No')
else:
    print('Yes')
    for i in range(1,len(dis)):
        print(dis[i])

Fixed submission:
from collections import deque

n,m = map(int, input().split())

path = [[] for _ in range(n)]

for i in range(m):
    a,b = map(int, input().split())
    path[a-1].append(b)
    path[b-1].append(a)
    
d = deque([0])
dis = [-1 for _ in range(n)]
dis[0] = 0

while d:
    hop = d.popleft()
    for i in path[hop]:
        if dis[i-1] == -1:
            d.append(i-1)
            dis[i-1] = hop+1
            
if -1 in dis:
    print('No')
else:
    print('Yes')
    for i in range(1,len(dis)):
        print(dis[i])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import deque

ab = np.array([], int)
n,m = map(int, input().split())

for i in range(m):
    ab = np.append(ab, list(map(int, input().split())), axis=0)

ab = ab.reshape(m,2)

path = []

for i in range(n):
    path.append([])

for i in range(m):
    path[ab[i][0]-1].append(ab[i][1])
    path[ab[i][1]-1].append(ab[i][0])
    
d = deque([0])
dis = np.ones(n, int) * -1
dis[0] = 0

while len(d) != 0:
    hop = d.popleft()
    for i in path[hop]:
        if dis[i-1] == -1:
            d.append(i-1)
            dis[i-1] = hop+1
    
    hop += 1
    
if np.count_nonzero(dis)+1 != n:
    print('No')
else:
    print('Yes')
    for i in range(1,len(dis)):
        print(dis[i])

Fixed submission:
from collections import deque

n,m = map(int, input().split())

path = [[] for _ in range(n)]

for i in range(m):
    a,b = map(int, input().split())
    path[a-1].append(b)
    path[b-1].append(a)
    
d = deque([0])
dis = [-1 for _ in range(n)]
dis[0] = 0

while d:
    hop = d.popleft()
    for i in path[hop]:
        if dis[i-1] == -1:
            d.append(i-1)
            dis[i-1] = hop+1
            
if -1 in dis:
    print('No')
else:
    print('Yes')
    for i in range(1,len(dis)):
        print(dis[i])

Buggy python submission (verdict: Runtime Error):
import numpy as np
from collections import deque

ab = np.array([])
n,m = map(int, input().split())

for i in range(m):
    ab = np.append(ab, list(map(int, input().split())), axis=0)

ab = ab.reshape(m,2)

Map = np.zeros((n,n),int)

for i in range(m):
    Map[int(ab[i][0]-1)][int(ab[i][1]-1)] = 1
    Map[int(ab[i][1]-1)][int(ab[i][0]-1)] = 1
    
d = deque([0])
dis = np.zeros(n, int)
appended = np.zeros(n)
appended[0] = 1

while len(d) != 0:
    hop = d.popleft()
    col = Map[hop]
    for i in range(len(col)):
        if col[i] == 1 and appended[i] == 0:
            d.append(i)
            dis[i] = hop+1
            appended[i] = 1
    
    hop += 1
    
for i in range(1,len(dis)):
    print(dis[i])

Fixed submission:
from collections import deque

n,m = map(int, input().split())

path = [[] for _ in range(n)]

for i in range(m):
    a,b = map(int, input().split())
    path[a-1].append(b)
    path[b-1].append(a)
    
d = deque([0])
dis = [-1 for _ in range(n)]
dis[0] = 0

while d:
    hop = d.popleft()
    for i in path[hop]:
        if dis[i-1] == -1:
            d.append(i-1)
            dis[i-1] = hop+1
            
if -1 in dis:
    print('No')
else:
    print('Yes')
    for i in range(1,len(dis)):
        print(dis[i])