Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().split()))
edge = [[] for k in range(n)]
for k in range(m):
    a, b = list(map(int, input().split()))
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

start = 0

from collections import deque
que = deque([start])
done = {start}
depth = [1e9]  * n
depth[start] = 0
parents = [-1] * n
while True:
    if len(que) == 0:
        break
    now = que.popleft()
    dep = depth[now]
    for node in edge[now]:
        if node not in done:
            if dep < depth[node]:
                depth[node] = dep + 1
                parents[node] = now
                que.append(node)
    done.add(now)
#     print(now)
if max(depth) == 1e9:
    print("No")
else:
    print("Yes")
    for k in range(1, n):
        print(parents[k] + 1)

Fixed submission:
n, m = list(map(int, input().split()))
edge = [[] for k in range(n)]
for k in range(m):
    a, b = list(map(int, input().split()))
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

start = 0

from collections import deque
que = deque([start])
done = {start}
depth = [1e9]  * n
depth[start] = 0
parents = [-1] * n
while True:
    if len(que) == 0:
        break
    now = que.popleft()
    dep = depth[now]
    
    for node in edge[now]:
        if node not in done:
#             if dep < depth[node]:
            depth[node] = dep + 1
            parents[node] = now
            que.append(node)
        done.add(node)
#     done.add(now)
#     print(now)
if max(depth) == 1e9:
    print("No")
else:
    print("Yes")
    for k in range(1, n):
        print(parents[k] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().split()))
edge = [[] for k in range(n)]
for k in range(m):
    a, b = list(map(int, input().split()))
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

start = 0

from collections import deque
que = deque([start])
done = {start}
depth = [1e9]  * n
depth[start] = 0
parents = [-1] * n
while True:
    if len(que) == 0:
        break
    now = que.popleft()
    dep = depth[now]
    for node in edge[now]:
        if node not in done:
            que.append(node)
            if dep < depth[node]:
                depth[node] = dep + 1
                parents[node] = now
    done.add(now)
#     print(now)
if max(depth) == 1e9:
    print("No")
else:
    print("Yes")
    for k in range(1, n):
        print(parents[k] + 1)

Fixed submission:
n, m = list(map(int, input().split()))
edge = [[] for k in range(n)]
for k in range(m):
    a, b = list(map(int, input().split()))
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

start = 0

from collections import deque
que = deque([start])
done = {start}
depth = [1e9]  * n
depth[start] = 0
parents = [-1] * n
while True:
    if len(que) == 0:
        break
    now = que.popleft()
    dep = depth[now]
    
    for node in edge[now]:
        if node not in done:
#             if dep < depth[node]:
            depth[node] = dep + 1
            parents[node] = now
            que.append(node)
        done.add(node)
#     done.add(now)
#     print(now)
if max(depth) == 1e9:
    print("No")
else:
    print("Yes")
    for k in range(1, n):
        print(parents[k] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().split()))
edge = [[] for k in range(n)]
for k in range(m):
    a, b = list(map(int, input().split()))
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

from collections import deque
def dijkstra(start, edge_list):
    """
    edge_list = [[1, 2], [0, 2], [1, 3, 0], [2]]
    start = 0
    [0, 1, 1, 2] == dijkstra(start, edge_list, n)
    """
    
    n = len(edge_list)
    dist = [int(2e9) for _ in range(n)]
    dist[start] = 0
    parents = [0 for _ in range(n)]
    stack = deque([start])
    while len(stack) != 0:
        start = stack.pop()
        next_list = edge_list[start]
        for nex in next_list:
            if dist[start] + 1 < dist[nex]:
                dist[nex] = dist[start] + 1 
                stack.append(nex)
                parents[nex] = start
                
    return dist, parents

dist, parents = dijkstra(0, edge)

if max(dist) == int(2e9):
    print("No")
else:
    print("Yes")
    for k in range(1, n):
        print(parents[k] + 1)

Fixed submission:
n, m = list(map(int, input().split()))
edge = [[] for k in range(n)]
for k in range(m):
    a, b = list(map(int, input().split()))
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

start = 0

from collections import deque
que = deque([start])
done = {start}
depth = [1e9]  * n
depth[start] = 0
parents = [-1] * n
while True:
    if len(que) == 0:
        break
    now = que.popleft()
    dep = depth[now]
    
    for node in edge[now]:
        if node not in done:
#             if dep < depth[node]:
            depth[node] = dep + 1
            parents[node] = now
            que.append(node)
        done.add(node)
#     done.add(now)
#     print(now)
if max(depth) == 1e9:
    print("No")
else:
    print("Yes")
    for k in range(1, n):
        print(parents[k] + 1)