Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
from collections import deque
import sys
input = sys.std.readline

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

que = deque()
dist = [float('inf')] * n
prev = [-1] * n
dist[0] = 0
que.append(0)
while que:
    now = que.popleft()
    for edge in edges[now]:
        if dist[edge] > dist[now] + 1:
            dist[edge] = dist[now] + 1
            prev[edge] = now + 1
            que.append(edge)


print('Yes')
for i in range(1, n):
    print(prev[i])



Fixed submission:
#!/usr/bin/env python3
from collections import deque
# import sys
# input = sys.std.readline

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

que = deque()
dist = [float('inf')] * n
prev = [-1] * n
dist[0] = 0
que.append(0)
while que:
    now = que.popleft()
    for edge in edges[now]:
        if dist[edge] > dist[now] + 1:
            dist[edge] = dist[now] + 1
            prev[edge] = now + 1
            que.append(edge)


print('Yes')
for i in range(1, n):
    print(prev[i])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from collections import deque

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

que = deque()
dist = [float('inf')] * n
prev = [-1] * n
dist[0] = 0
que.append(0)
while que:
    now = que.pop()
    for edge in edges[now]:
        if dist[edge] > dist[now] + 1:
            dist[edge] = dist[now] + 1
            prev[edge] = now + 1
            que.append(edge)


print('Yes')
for i in range(1, n):
    print(prev[i])



Fixed submission:
#!/usr/bin/env python3
from collections import deque
# import sys
# input = sys.std.readline

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

que = deque()
dist = [float('inf')] * n
prev = [-1] * n
dist[0] = 0
que.append(0)
while que:
    now = que.popleft()
    for edge in edges[now]:
        if dist[edge] > dist[now] + 1:
            dist[edge] = dist[now] + 1
            prev[edge] = now + 1
            que.append(edge)


print('Yes')
for i in range(1, n):
    print(prev[i])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from collections import deque
import sys

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

que = deque()
dist = [float('inf')] * n
dist[0] = 0
que.append(0)
while que:
    now = que.pop()
    for edge in edges[now]:
        if dist[edge] > dist[now] + 1:
            dist[edge] = dist[now] + 1
            que.append(edge)

# print(dist)
arrow = [0] * n
for i, j in enumerate(dist):
    if i == 0:
        continue
    idxs = []
    for idx in range(n):
        if dist[idx] == j - 1:
            idxs.append(idx)
    for edge in edges[i]:
        if edge in idxs:
            arrow[i] = edge + 1
            break
    if arrow[i] == 0:
        print('No')
        sys.exit()

print('Yes')
for i in range(1, n):
    print(arrow[i])


Fixed submission:
#!/usr/bin/env python3
from collections import deque
# import sys
# input = sys.std.readline

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

que = deque()
dist = [float('inf')] * n
prev = [-1] * n
dist[0] = 0
que.append(0)
while que:
    now = que.popleft()
    for edge in edges[now]:
        if dist[edge] > dist[now] + 1:
            dist[edge] = dist[now] + 1
            prev[edge] = now + 1
            que.append(edge)


print('Yes')
for i in range(1, n):
    print(prev[i])

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from collections import deque
import sys

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

que = deque()
dist = [float('inf')] * n
dist[0] = 0
que.append(0)
while que:
    now = que.pop()
    for edge in edges[now]:
        if dist[edge] > dist[now] + 1:
            dist[edge] = dist[now] + 1
            que.append(edge)

# print(dist)
arrow = [0] * n
for i, j in enumerate(dist):
    if i == 0:
        continue
    idxs = []
    for idx in range(n):
        if dist[idx] == j - 1:
            idxs.append(idx)
    for edge in edges[i]:
        if edge in idxs:
            flg = True
            arrow[i] = edge + 1
    if arrow[i] == 0:
        print('No')
        sys.exit()

print('Yes')
for i in range(1, n):
    print(arrow[i])



Fixed submission:
#!/usr/bin/env python3
from collections import deque
# import sys
# input = sys.std.readline

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

que = deque()
dist = [float('inf')] * n
prev = [-1] * n
dist[0] = 0
que.append(0)
while que:
    now = que.popleft()
    for edge in edges[now]:
        if dist[edge] > dist[now] + 1:
            dist[edge] = dist[now] + 1
            prev[edge] = now + 1
            que.append(edge)


print('Yes')
for i in range(1, n):
    print(prev[i])