Buggy python submission (verdict: Runtime Error):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()

rt = [[] for i in range(n)]
srb = [None] * n
dk = [10**10]*n


for i in range(m):
    a,b = mi()
    rt[a-1].append(b-1)
    rt[b-1].append(a-1)

from collections import deque
l = deque()

srb[0] = 0
for i in rt[0]:
    l.append(i)
    srb[i] = 1

while len(l) != 0:
    print(l)
    c = l.popleft()
    for i in rt[c]:
        if srb[i] == None:
            l.append(i)
            srb[i] = c+1

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




Fixed submission:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()

rt = [[] for i in range(n)]
srb = [None] * n
dk = [10**10]*n


for i in range(m):
    a,b = mi()
    rt[a-1].append(b-1)
    rt[b-1].append(a-1)

from collections import deque
l = deque()

srb[0] = 0
for i in rt[0]:
    l.append(i)
    srb[i] = 1

while len(l) != 0:
    c = l.popleft()
    for i in rt[c]:
        if srb[i] == None:
            l.append(i)
            srb[i] = c+1

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

Buggy python submission (verdict: Time Limit Exceeded):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
rt = [[] for i in range(n)]
dk = [10**10] * n
srb = [None]*n

for i in range(m):
    a,b = mi()
    rt[a-1].append(b-1)
    rt[b-1].append(a-1)

d = dict()
dk[0] = 0
for i in rt[0]:
    d[i] = 1
    dk[i] = 1
    srb[i] = 1

while len(d) != 0:
# for j in range(20):
    # ルートが最小のnodeを見つける
    mincost = 10**6
    minnode, mincost = min(d.items(),key=lambda x: x[1])
    # for i in l:
    #     if mincost > dk[i]:
    #         mincost = dk[i]
    #         minnode = i
    # そのnodeの数字を確定し、
    del d[minnode]
        
    # 隣接する確定してないnodeにコストを上書き（小さければ）
    # queueに隣接nodeをappend
    for i in rt[minnode]:
        if dk[i] > dk[minnode]:
            dk[i] = dk[minnode]+1
            srb[i] = minnode+1
            d[i] = dk[minnode]+1

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






Fixed submission:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()

rt = [[] for i in range(n)]
srb = [None] * n
dk = [10**10]*n


for i in range(m):
    a,b = mi()
    rt[a-1].append(b-1)
    rt[b-1].append(a-1)

from collections import deque
l = deque()

srb[0] = 0
for i in rt[0]:
    l.append(i)
    srb[i] = 1

while len(l) != 0:
    c = l.popleft()
    for i in rt[c]:
        if srb[i] == None:
            l.append(i)
            srb[i] = c+1

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

Buggy python submission (verdict: Time Limit Exceeded):
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
rt = [[] for i in range(n)]
dk = [10**10] * n
srb = [None]*n

for i in range(m):
    a,b = mi()
    rt[a-1].append(b-1)
    rt[b-1].append(a-1)

l = []
dk[0] = 0
for i in rt[0]:
    l.append(i)
    dk[i] = 1
    srb[i] = 1

while len(l) != 0:
# for j in range(20):
    # ルートが最小のnodeを見つける
    mincost = 10**6
    for i in l:
        if mincost > dk[i]:
            mincost = dk[i]
            minnode = i
    # そのnodeの数字を確定し、
    l.remove(minnode)
        
    # 隣接する確定してないnodeにコストを上書き（小さければ）
    # queueに隣接nodeをappend
    for i in rt[minnode]:
        if dk[i] > dk[minnode]:
            dk[i] = dk[minnode]+1
            srb[i] = minnode+1
            if i not in l:
                l.append(i)

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






Fixed submission:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()

rt = [[] for i in range(n)]
srb = [None] * n
dk = [10**10]*n


for i in range(m):
    a,b = mi()
    rt[a-1].append(b-1)
    rt[b-1].append(a-1)

from collections import deque
l = deque()

srb[0] = 0
for i in rt[0]:
    l.append(i)
    srb[i] = 1

while len(l) != 0:
    c = l.popleft()
    for i in rt[c]:
        if srb[i] == None:
            l.append(i)
            srb[i] = c+1

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