Buggy python submission (verdict: Runtime Error):
from collections import deque
 
n,m=map(int,input().split())
node=[[] for _ in range(n)]
 
for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)
 

seen=[False]*n
depth=[-1]*n
todo=deque([])
todo.append(0)
depth[0]=1

    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if depth[i]==-1:
            depth[i]=depth[p]+1
            todo.append(i)
    todo.popleft()
 
 

if min(depth)==-1:
    print('No')
else:
    print("Yes")
    for i in range(1,n):
        for j in node(i):
            if depth[i]>depth[j]:
                print(j+1)
                break

Fixed submission:
from collections import deque
 
n,m=map(int,input().split())
node=[[] for _ in range(n)]
 
for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)
 

seen=[False]*n
depth=[-1]*n
todo=deque([])
todo.append(0)
depth[0]=1

    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if depth[i]==-1:
            depth[i]=depth[p]+1
            todo.append(i)
    todo.popleft()
 
 

if min(depth)==-1:
    print('No')
else:
    print("Yes")
    for i in range(1,n):
        for j in node[i]:
            if depth[i]>depth[j]:
                print(j+1)
                break

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

n,m=map(int,input().split())
node=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)


seen=[False]*n
depth=[0]*n
todo=deque([])
todo.append(0)
    
    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if not (i in todo):
            depth[i]+=depth[p]+1
            todo.append(i)
    todo.popleft()



#print(depth)

sekai=[]

for i in range(1,n):
    for j in node[i]:
        if depth[j]<depth[i]:
            sekai.append(j+1)
            break

if len(sekai)!=n-1:
    print('No')
else:
    print("Yes")
    for a in sekai:
        print(a)

Fixed submission:
from collections import deque
 
n,m=map(int,input().split())
node=[[] for _ in range(n)]
 
for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)
 

seen=[False]*n
depth=[-1]*n
todo=deque([])
todo.append(0)
depth[0]=1

    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if depth[i]==-1:
            depth[i]=depth[p]+1
            todo.append(i)
    todo.popleft()
 
 

if min(depth)==-1:
    print('No')
else:
    print("Yes")
    for i in range(1,n):
        for j in node[i]:
            if depth[i]>depth[j]:
                print(j+1)
                break

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

n,m=map(int,input().split())
node=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)


seen=[False]*n
depth=[0]*n
todo=deque([])
todo.append(0)
    
    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if not (i in todo):
            depth[i]+=depth[p]+1
            todo.append(i)
    todo.popleft(0)



#print(depth)

sekai=[]

for i in range(1,n):
    for j in node[i]:
        if depth[j]<depth[i]:
            sekai.append(j+1)
            break
#print(sekai)

if len(sekai)!=(n-1):
    print('No')
else:
    print("Yes")
    for a in sekai:
        print(a)

Fixed submission:
from collections import deque
 
n,m=map(int,input().split())
node=[[] for _ in range(n)]
 
for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)
 

seen=[False]*n
depth=[-1]*n
todo=deque([])
todo.append(0)
depth[0]=1

    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if depth[i]==-1:
            depth[i]=depth[p]+1
            todo.append(i)
    todo.popleft()
 
 

if min(depth)==-1:
    print('No')
else:
    print("Yes")
    for i in range(1,n):
        for j in node[i]:
            if depth[i]>depth[j]:
                print(j+1)
                break

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

n,m=map(int,input().split())
node=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)


seen=[False]*n
depth=[0]*n
todo=[]
todo.append(0)
    
    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if not (i in todo):
            depth[i]+=depth[p]+1
            todo.append(i)
    todo.pop(0)



#print(depth)

sekai=[]

for i in range(1,n):
    for j in node[i]:
        if depth[j]<depth[i]:
            sekai.append(j+1)
            break
#print(sekai)

if len(sekai)!=(n-1):
    print('No')
else:
    print("Yes")
    for a in sekai:
        print(a)

Fixed submission:
from collections import deque
 
n,m=map(int,input().split())
node=[[] for _ in range(n)]
 
for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)
 

seen=[False]*n
depth=[-1]*n
todo=deque([])
todo.append(0)
depth[0]=1

    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if depth[i]==-1:
            depth[i]=depth[p]+1
            todo.append(i)
    todo.popleft()
 
 

if min(depth)==-1:
    print('No')
else:
    print("Yes")
    for i in range(1,n):
        for j in node[i]:
            if depth[i]>depth[j]:
                print(j+1)
                break

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

n,m=map(int,input().split())
node=[[] for _ in range(n)]

for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)


seen=[False]*n
depth=[0]*n
todo=[]
todo.append(0)
    
    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if not (i in todo):
            depth[i]+=depth[p]+1
            todo.append(i)
    todo.pop(0)



#print(depth)

sekai=[]

for i in range(1,n):
    for j in node[i]:
        if depth[j]<depth[i]:
            sekai.append(j+1)
            break
#print(sekai)

if len(sekai)!=(n-1):
    print('No')
else:
    print("Yes")
    for a in sekai:
        print(a)

Fixed submission:
from collections import deque
 
n,m=map(int,input().split())
node=[[] for _ in range(n)]
 
for _ in range(m):
    a,b=map(lambda x:int(x)-1,input().split())
    node[a].append(b)
    node[b].append(a)
    
#print(node)
 

seen=[False]*n
depth=[-1]*n
todo=deque([])
todo.append(0)
depth[0]=1

    
while len(todo)>0:
    p=todo[0]
    
    seen[p]=True
    to=node[p]
    for i in to:
        if seen[i]:continue
        if depth[i]==-1:
            depth[i]=depth[p]+1
            todo.append(i)
    todo.popleft()
 
 

if min(depth)==-1:
    print('No')
else:
    print("Yes")
    for i in range(1,n):
        for j in node[i]:
            if depth[i]>depth[j]:
                print(j+1)
                break