Buggy python submission (verdict: Runtime Error):
port math
from queue import Queue
 
n, m = [int(i) for i in input().split()]
 
root = [[ for _ in range(n+1)] for _ in range(n+1)]
 
for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a][b] = 1
    root[b][a] = 1
 
 
check = [0 for _ in range(n+1)]
check[1] = 1
 
q = Queue()
q.put(1)
 
while ( not q.empty() ):
    now = q.get()
    for i in range(1,n+1):
        if(root[now][i] == 1 and check[i] == 0):
            check[i] = now
            q.put(i)
 
flag = 1
for i in range(2, n+1):
    if(check[i] == 0):
        flag = 0
 
if(flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")

Fixed submission:
import math
from queue import Queue

n, m = [int(i) for i in input().split()]

root = [[] for _ in range(n+1)]

for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a].append(b)
    root[b].append(a)

check = [0 for _ in range(n + 1)]
check[1] = 1

q = Queue()
q.put(1)

while (not q.empty()):
    now = q.get()
    for i in root[now]:
        if (check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n + 1):
    if (check[i] == 0):
        flag = 0

if (flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import math
from queue import Queue
from collections import defaultdict

n, m = [int(i) for i in input().split()]


root = defaultdict(lambda: defaultdict(int))


for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a][b] = 1
    root[b][a] = 1

check = [0 for _ in range(n + 1)]
check[1] = 1

q = Queue()
q.put(1)

while (not q.empty()):
    now = q.get()
    for i in range(1, n + 1):
        if (root[now][i] == 1 and check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n + 1):
    if (check[i] == 0):
        flag = 0

if (flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")

Fixed submission:
import math
from queue import Queue

n, m = [int(i) for i in input().split()]

root = [[] for _ in range(n+1)]

for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a].append(b)
    root[b].append(a)

check = [0 for _ in range(n + 1)]
check[1] = 1

q = Queue()
q.put(1)

while (not q.empty()):
    now = q.get()
    for i in root[now]:
        if (check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n + 1):
    if (check[i] == 0):
        flag = 0

if (flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import math
from queue import Queue
from collections import defaultdict

n, m = [int(i) for i in input().split()]


root = defaultdict(lambda: defaultdict(int))


for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a][b] = 1
    root[b][a] = 1

check = [0 for _ in range(n + 1)]
check[1] = 1

q = Queue()
q.put(1)

while (not q.empty()):
    now = q.get()
    for i in range(1, n + 1):
        if (root[now][i] == 1 and check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n + 1):
    if (check[i] == 0):
        flag = 0

if (flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")

Fixed submission:
import math
from queue import Queue

n, m = [int(i) for i in input().split()]

root = [[] for _ in range(n+1)]

for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a].append(b)
    root[b].append(a)

check = [0 for _ in range(n + 1)]
check[1] = 1

q = Queue()
q.put(1)

while (not q.empty()):
    now = q.get()
    for i in root[now]:
        if (check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n + 1):
    if (check[i] == 0):
        flag = 0

if (flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import math
from queue import Queue
from collections import defaultdict

n, m = [int(i) for i in input().split()]


root = [defaultdict(int) for _ in range(n+1)]


for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a][b] = 1
    root[b][a] = 1

check = [0 for _ in range(n + 1)]
check[1] = 1

q = Queue()
q.put(1)

while (not q.empty()):
    now = q.get()
    for i in range(1, n + 1):
        if (root[now][i] == 1 and check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n + 1):
    if (check[i] == 0):
        flag = 0

if (flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")

Fixed submission:
import math
from queue import Queue

n, m = [int(i) for i in input().split()]

root = [[] for _ in range(n+1)]

for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a].append(b)
    root[b].append(a)

check = [0 for _ in range(n + 1)]
check[1] = 1

q = Queue()
q.put(1)

while (not q.empty()):
    now = q.get()
    for i in root[now]:
        if (check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n + 1):
    if (check[i] == 0):
        flag = 0

if (flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
from queue import Queue

n, m = [int(i) for i in input().split()]

root = np.zeros((n+1,n+1),dtype=np.int)

for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a][b] = 1
    root[b][a] = 1


check = [0 for _ in range(n+1)]
check[1] = 1

q = Queue()
q.put(1)

while ( not q.empty() ):
    now = q.get()
    for i in range(1,n+1):
        if(root[now][i] == 1 and check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n+1):
    if(check[i] == 0):
        flag = 0

if(flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")



Fixed submission:
import math
from queue import Queue

n, m = [int(i) for i in input().split()]

root = [[] for _ in range(n+1)]

for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a].append(b)
    root[b].append(a)

check = [0 for _ in range(n + 1)]
check[1] = 1

q = Queue()
q.put(1)

while (not q.empty()):
    now = q.get()
    for i in root[now]:
        if (check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n + 1):
    if (check[i] == 0):
        flag = 0

if (flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import math
from queue import Queue

n, m = [int(i) for i in input().split()]

root = [[0 for _ in range(n+1)] for _ in range(n+1)]

for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a][b] = 1
    root[b][a] = 1


check = [0 for _ in range(n+1)]
check[1] = 1

q = Queue()
q.put(1)

while ( not q.empty() ):
    now = q.get()
    for i in range(1,n+1):
        if(root[now][i] == 1 and check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n+1):
    if(check[i] == 0):
        flag = 0

if(flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")



Fixed submission:
import math
from queue import Queue

n, m = [int(i) for i in input().split()]

root = [[] for _ in range(n+1)]

for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a].append(b)
    root[b].append(a)

check = [0 for _ in range(n + 1)]
check[1] = 1

q = Queue()
q.put(1)

while (not q.empty()):
    now = q.get()
    for i in root[now]:
        if (check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n + 1):
    if (check[i] == 0):
        flag = 0

if (flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")

Buggy python submission (verdict: Time Limit Exceeded):
import math
from queue import Queue

n, m = [int(i) for i in input().split()]

root = [[0 for _ in range(n+1)] for _ in range(n+1)]

for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a][b] = 1
    root[b][a] = 1


check = [0 for _ in range(n+1)]
check[1] = 1

q = Queue()
q.put(1)

while ( not q.empty() ):
    now = q.get()
    for i in range(1,n+1):
        if(root[now][i] == 1 and check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n+1):
    if(check[i] == 0):
        flag = 0

if(flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")



Fixed submission:
import math
from queue import Queue

n, m = [int(i) for i in input().split()]

root = [[] for _ in range(n+1)]

for i in range(m):
    a, b = [int(i) for i in input().split()]
    root[a].append(b)
    root[b].append(a)

check = [0 for _ in range(n + 1)]
check[1] = 1

q = Queue()
q.put(1)

while (not q.empty()):
    now = q.get()
    for i in root[now]:
        if (check[i] == 0):
            check[i] = now
            q.put(i)

flag = 1
for i in range(2, n + 1):
    if (check[i] == 0):
        flag = 0

if (flag == 1):
    print("Yes")
    for j in range(2, n + 1):
        print(check[j])
else:
    print("No")