Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import deque
N,M = [int(i) for i in input().split()]
roads = []
for _ in range(M):
    A,B = [int(i) for i in input().split()]
    roads.append([A,B])
    roads.append([B,A])
roads = np.array(roads)
places = [0]*(N+1)
places[1] = 1
q = deque([1])
vis = [False]*(N+1)
vis[1] = True
while q:
    now = q.popleft()
    L = roads[roads[:,0] == now][:,1]
    for j in L:
        if vis[j]:
            continue
        vis[j] = True
        places[j] = now
        q.append(j)

print("Yes")
s = "\n".join(map(str, places[2:]))
print(s)

Fixed submission:
import numpy as np
from collections import deque
N,M = [int(i) for i in input().split()]
roads = [[] for _ in range(N+1)]
for _ in range(M):
    A,B = [int(i) for i in input().split()]
    roads[A].append(B)
    roads[B].append(A)
places = [0]*(N+1)
places[1] = 1
q = deque([1])
vis = [False]*(N+1)
vis[1] = True
while q:
    now = q.popleft()
    L = roads[now]
    for j in L:
        if vis[j]:
            continue
        vis[j] = True
        places[j] = now
        q.append(j)

print("Yes")
s = "\n".join(map(str, places[2:]))
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import deque
N,M = [int(i) for i in input().split()]
roads = []
for _ in range(M):
    A,B = [int(i) for i in input().split()]
    roads.append([A,B])
    roads.append([B,A])
roads = np.array(roads)
places = [0]*(N+1)
places[1] = 1
q = deque([1])
vis = [False]*(N+1)
vis[1] = True
while q:
    now = q.pop()
    L = roads[roads[:,0] == now][:,1]
    for j in L:
        if vis[j]:
            continue
        vis[j] = True
        places[j] = now
        q.appendleft(j)

print("Yes")
s = "\n".join(map(str, places[2:]))
print(s)

Fixed submission:
import numpy as np
from collections import deque
N,M = [int(i) for i in input().split()]
roads = [[] for _ in range(N+1)]
for _ in range(M):
    A,B = [int(i) for i in input().split()]
    roads[A].append(B)
    roads[B].append(A)
places = [0]*(N+1)
places[1] = 1
q = deque([1])
vis = [False]*(N+1)
vis[1] = True
while q:
    now = q.popleft()
    L = roads[now]
    for j in L:
        if vis[j]:
            continue
        vis[j] = True
        places[j] = now
        q.append(j)

print("Yes")
s = "\n".join(map(str, places[2:]))
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import deque
N,M = [int(i) for i in input().split()]
roads = []
for _ in range(M):
    A,B = [int(i) for i in input().split()]
    roads.append([A,B])
    roads.append([B,A])
roads = np.array(roads)
places = [0]*(N+1)
places[1] = 1
q = deque([1])
n = 1
while n < N:
    i = q.pop()
    L = roads[roads[:,0] == i][:,1]
    for j in L:
        if places[j] == 0:
            places[j] = i
            q.appendleft(j)
            n += 1
print("Yes")
for i in range(2,N+1):
    print(places[i])


Fixed submission:
import numpy as np
from collections import deque
N,M = [int(i) for i in input().split()]
roads = [[] for _ in range(N+1)]
for _ in range(M):
    A,B = [int(i) for i in input().split()]
    roads[A].append(B)
    roads[B].append(A)
places = [0]*(N+1)
places[1] = 1
q = deque([1])
vis = [False]*(N+1)
vis[1] = True
while q:
    now = q.popleft()
    L = roads[now]
    for j in L:
        if vis[j]:
            continue
        vis[j] = True
        places[j] = now
        q.append(j)

print("Yes")
s = "\n".join(map(str, places[2:]))
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
from collections import deque
N,M = [int(i) for i in input().split()]
roads = []
for _ in range(M):
    A,B = [int(i) for i in input().split()]
    roads.append([A,B])
    roads.append([B,A])
roads = np.array(roads)
places = [0]*(N+1)
places[1] = 1
q = deque([1])
while min(places[1:]) == 0:
    i = q.pop()
    L = roads[roads[:,0] == i][:,1]
    for j in L:
        if places[j] == 0:
            places[j] = i
            q.appendleft(j)
print("Yes")
for i in range(2,N+1):
    print(places[i])

Fixed submission:
import numpy as np
from collections import deque
N,M = [int(i) for i in input().split()]
roads = [[] for _ in range(N+1)]
for _ in range(M):
    A,B = [int(i) for i in input().split()]
    roads[A].append(B)
    roads[B].append(A)
places = [0]*(N+1)
places[1] = 1
q = deque([1])
vis = [False]*(N+1)
vis[1] = True
while q:
    now = q.popleft()
    L = roads[now]
    for j in L:
        if vis[j]:
            continue
        vis[j] = True
        places[j] = now
        q.append(j)

print("Yes")
s = "\n".join(map(str, places[2:]))
print(s)