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

def main():
    n,m = map(int, input().split())
    graph = [[] for _ in range(n)]
    for i in range(1,m+1):
        a,b = map(int, input().split())
        graph[a-1].append(b)
        graph[b-1].append(a)
    
    q = deque([1])
    prev=[1]
    siru = [0] * (n-1)
    while q:
    
        now = q.popleft()
        
        next = graph[now-1]
    
        
        for n in next:
            if not n in prev: 
                q.append(n)
                prev.append(n)
                siru[n-2] = now
        if not 0 in siru:
            break
    
    
    
    print("Yes")
    print("\n".join(map(str, siru)))
if __name__ == "__main__":
    main()

        

Fixed submission:
from collections import deque

def main():
    n,m = map(int, input().split())
    graph = [[] for _ in range(n)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1].append(b)
        graph[b-1].append(a)
    
    q = deque([1])
    prev=[1]
    siru = [0] * n
    siru[0] = 1
    while q:
    
        now = q.popleft()
        
        next = graph[now-1]
    
        
        for n in next:
            if not siru[n-1]: 
                q.append(n)
                siru[n-1] = now
    
    
    print("Yes")
    print("\n".join(map(str, siru[1:])))
if __name__ == "__main__":
    main()

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


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

q = deque([1])
prev=[1]
siru = [0] * (n-1)
while q:

    now = q.popleft()
    
    next = graph[now-1]

    
    for n in next:
        if not n in prev: 
            q.append(n)
            prev.append(n)
            siru[n-2] = now
    if not 0 in siru:
        break



print("Yes")
print("\n".join(map(str, siru)))

        

Fixed submission:
from collections import deque

def main():
    n,m = map(int, input().split())
    graph = [[] for _ in range(n)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1].append(b)
        graph[b-1].append(a)
    
    q = deque([1])
    prev=[1]
    siru = [0] * n
    siru[0] = 1
    while q:
    
        now = q.popleft()
        
        next = graph[now-1]
    
        
        for n in next:
            if not siru[n-1]: 
                q.append(n)
                siru[n-1] = now
    
    
    print("Yes")
    print("\n".join(map(str, siru[1:])))
if __name__ == "__main__":
    main()

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


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

q = deque([1])
prev=[1]
siru = [0] * (n-1)
while q:

    now = q.popleft()
    
    next = graph[now-1]

    
    for n in next:
        if not n in prev: 
            q.append(n)
            prev.append(n)
            siru[n-2] = now
    if not 0 in siru:
        break



print("Yes")
print("\n".join(map(str, siru)))

        

Fixed submission:
from collections import deque

def main():
    n,m = map(int, input().split())
    graph = [[] for _ in range(n)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1].append(b)
        graph[b-1].append(a)
    
    q = deque([1])
    prev=[1]
    siru = [0] * n
    siru[0] = 1
    while q:
    
        now = q.popleft()
        
        next = graph[now-1]
    
        
        for n in next:
            if not siru[n-1]: 
                q.append(n)
                siru[n-1] = now
    
    
    print("Yes")
    print("\n".join(map(str, siru[1:])))
if __name__ == "__main__":
    main()

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


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

q = deque([1])
prev=[1]
siru = [0] * (n-1)
while q:

    now = q.popleft()
    
    next = graph[now-1]

    
    for n in next:
        if not n in prev: 
            q.append(n)
            prev.append(n)
            siru[n-2] = now
    if not 0 in siru:
        break



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

        

Fixed submission:
from collections import deque

def main():
    n,m = map(int, input().split())
    graph = [[] for _ in range(n)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1].append(b)
        graph[b-1].append(a)
    
    q = deque([1])
    prev=[1]
    siru = [0] * n
    siru[0] = 1
    while q:
    
        now = q.popleft()
        
        next = graph[now-1]
    
        
        for n in next:
            if not siru[n-1]: 
                q.append(n)
                siru[n-1] = now
    
    
    print("Yes")
    print("\n".join(map(str, siru[1:])))
if __name__ == "__main__":
    main()

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


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

q = deque([1])
prev=[1]
siru = [0] * (n-1)
while q:

    now = q.popleft()
    
    next = graph[now-1]

    
    for n in next:
        if not n in prev: 
            q.append(n)
            prev.append(n)
            siru[n-2] = now
    if not 0 in siru:
        break

if 0 in siru:
    print("No")
else:
    print("Yes")
    for i in range(len(siru)):
        print(siru[i])
    
        

Fixed submission:
from collections import deque

def main():
    n,m = map(int, input().split())
    graph = [[] for _ in range(n)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1].append(b)
        graph[b-1].append(a)
    
    q = deque([1])
    prev=[1]
    siru = [0] * n
    siru[0] = 1
    while q:
    
        now = q.popleft()
        
        next = graph[now-1]
    
        
        for n in next:
            if not siru[n-1]: 
                q.append(n)
                siru[n-1] = now
    
    
    print("Yes")
    print("\n".join(map(str, siru[1:])))
if __name__ == "__main__":
    main()

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


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

q = deque([1])
prev=[1]
siru = [0] * (n-1)
while q:

    now = q.popleft()
    
    next = graph[now-1]

    
    for n in next:
        if not n in prev: 
            q.append(n)
            prev.append(n)
            siru[n-2] = now

if 0 in siru:
    print("No")
else:
    print("Yes")
    for i in range(len(siru)):
        print(siru[i])
    
        

Fixed submission:
from collections import deque

def main():
    n,m = map(int, input().split())
    graph = [[] for _ in range(n)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1].append(b)
        graph[b-1].append(a)
    
    q = deque([1])
    prev=[1]
    siru = [0] * n
    siru[0] = 1
    while q:
    
        now = q.popleft()
        
        next = graph[now-1]
    
        
        for n in next:
            if not siru[n-1]: 
                q.append(n)
                siru[n-1] = now
    
    
    print("Yes")
    print("\n".join(map(str, siru[1:])))
if __name__ == "__main__":
    main()