Buggy python submission (verdict: Time Limit Exceeded):
import queue
n, m = map(int, input().split())
g = [[0] * n for i in range(n)]

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

root = [0] * n
count = 0
q = queue.Queue()
q.put(0)
root[0] = 1
count += 1
while not q.empty():
    p = q.get()
    for i in range(n):
        if root[i] <= 0 and g[p][i] > 0:
            q.put(i)
            root[i] = p + 1
            count += 1
            #print(p,i,count,root)
            if count >= n:
                break

if count < n:
    print('No')
    exit()
else:
    print('Yes')
    for i in range(1,n):
        print(root[i])




Fixed submission:
import queue
n, m = map(int, input().split())
g = [[] for _ in range(n+1)]

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

#print(g)

root = [0] * n
count = 0
q = queue.Queue()
q.put(0)
root[0] = 1
count += 1
while not q.empty():
    p = q.get()
    for i in g[p+1]:
        if root[i-1] <= 0:
            q.put(i-1)
            root[i-1] = p + 1
            count += 1
            #print(p,i,count,root)
            if count >= n:
                break


if count < n:
    print('No')
    exit()
else:
    print('Yes')
    for i in range(1,n):
        print(root[i])

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

def dijkstra(g,node_count):
    
    root = [-1] * node_count

    q = queue.Queue()
    q.put(0)
    root[0] = 0
    conf[0] = 1
    while not q.empty():

        p = q.get()
        conf[p] = 1
        for i in range(node_count):
            if conf[i] == 0 and g[p][i] > 0 and i != p:
                q.put(i)
                root[i] = p
                conf[i] = 1
                if sum(conf) == node_count:
                    break

    return root


n, m = map(int, input().split())
g = [[0] * n for i in range(n)]

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

root = [0] * n
count = 0
q = queue.Queue()
q.put(0)
root[0] = 1
count += 1
while not q.empty():
    p = q.get()
    for i in range(n):
        if root[i] <= 0 and g[p][i] > 0:
            q.put(i)
            root[i] = p + 1
            count += 1
            #print(p,i,count,root)
            if count >= n:
                break

if count < n:
    print('No')
    exit()
else:
    print('Yes')
    for i in range(1,n):
        print(root[i])




Fixed submission:
import queue
n, m = map(int, input().split())
g = [[] for _ in range(n+1)]

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

#print(g)

root = [0] * n
count = 0
q = queue.Queue()
q.put(0)
root[0] = 1
count += 1
while not q.empty():
    p = q.get()
    for i in g[p+1]:
        if root[i-1] <= 0:
            q.put(i-1)
            root[i-1] = p + 1
            count += 1
            #print(p,i,count,root)
            if count >= n:
                break


if count < n:
    print('No')
    exit()
else:
    print('Yes')
    for i in range(1,n):
        print(root[i])

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

def dijkstra(g,node_count):
    conf = [0] * node_count
    root = [-1] * node_count

    q = queue.Queue()
    q.put(0)
    root[0] = 0
    conf[0] = 1
    while not q.empty():

        p = q.get()
        conf[p] = 1
        for i in range(node_count):
            if conf[i] == 0 and g[p][i] > 0 and i != p:
                q.put(i)
                root[i] = p
                conf[i] = 1
                if sum(conf) == node_count:
                    break
                
    return root


n, m = map(int, input().split())
r = []
#g = np.zeros((n,n))
g = [[0] * n for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    g[a-1][b-1] = 1
    g[b-1][a-1] = 1
    #r.append([a,b])
#for i in range(n):
#    print(g[i])
#c = dijkstra_heapq(g,n,0)
#print(c)
c = dijkstra(g,n)

#c = np.array(c) + 1
#print(c)
ans = []
for i in range(1,n):
    if c[i] >= 0:
        ans.append(c[i]+1)
    else:
        print('No')
        exit()

print('Yes')
for i in range(len(ans)):
    print(ans[i])


Fixed submission:
import queue
n, m = map(int, input().split())
g = [[] for _ in range(n+1)]

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

#print(g)

root = [0] * n
count = 0
q = queue.Queue()
q.put(0)
root[0] = 1
count += 1
while not q.empty():
    p = q.get()
    for i in g[p+1]:
        if root[i-1] <= 0:
            q.put(i-1)
            root[i-1] = p + 1
            count += 1
            #print(p,i,count,root)
            if count >= n:
                break


if count < n:
    print('No')
    exit()
else:
    print('Yes')
    for i in range(1,n):
        print(root[i])

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

def dijkstra(g,node_count,start_index):

    INF = 10**9+7
    node = [INF] * node_count
    conf = [0] * node_count
    root = [-1] * node_count

    q = queue.Queue()
    q.put(0)
    root[0] = 0
    while not q.empty():

        p = q.get()
        conf[p] = 1
        for i in range(node_count):
            if root[i] < 0 and g[p][i] > 0 and i != p:
                q.put(i)
                root[i] = p

    return root


n, m = map(int, input().split())
r = []
#g = np.zeros((n,n))
g = [[0] * n for i in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    g[a-1][b-1] = 1
    g[b-1][a-1] = 1
    #r.append([a,b])
#for i in range(n):
#    print(g[i])
#c = dijkstra_heapq(g,n,0)
#print(c)
c = dijkstra(g,n,0)

#c = np.array(c) + 1
#print(c)
ans = []
for i in range(1,n):
    if c[i] >= 0:
        ans.append(c[i]+1)
    else:
        print('No')
        exit()

print('Yes')
for i in range(len(ans)):
    print(ans[i])


Fixed submission:
import queue
n, m = map(int, input().split())
g = [[] for _ in range(n+1)]

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

#print(g)

root = [0] * n
count = 0
q = queue.Queue()
q.put(0)
root[0] = 1
count += 1
while not q.empty():
    p = q.get()
    for i in g[p+1]:
        if root[i-1] <= 0:
            q.put(i-1)
            root[i-1] = p + 1
            count += 1
            #print(p,i,count,root)
            if count >= n:
                break


if count < n:
    print('No')
    exit()
else:
    print('Yes')
    for i in range(1,n):
        print(root[i])

Buggy python submission (verdict: Runtime Error):
import numpy as np

def dijkstra(graph,node_count,start_index):
    INF = 10**9+7
    node = [INF] * node_count
    conf = [0] * node_count
    root = [-1] * node_count

    node[start_index] = 0
    count = 0
    while sum(conf) < node_count:

        change = False

        min_node_dex = -1
        min_node_val = INF
        for i in range(node_count):
            if conf[i] == 0:
                if node[i] < min_node_val:
                    min_node_val = node[i]
                    min_node_dex = i
        conf[min_node_dex] = 1
        for i in range(node_count):
            if conf[i] == 0:
                if g[min_node_dex][i] > 0:
                    new_dist = node[min_node_dex] + g[min_node_dex][i]
                    if new_dist < node[i]:
                        node[i] = new_dist
                        root[i] = min_node_dex
                        change = True

        #print(node)
        #print(conf)
        #print(root)
        count += 1
        if not change:
            break
        #if count >= 10:
        #    break
    return root

n, m = map(int, input().split())
r = []
g = np.zeros((n,n),dtype=np.uint32)

for i in range(m):
    a, b = map(int, input().split())
    g[a-1][b-1] = 1
    g[b-1][a-1] = 1
    #r.append([a,b])

#c = dijkstra_heapq(g,n,0)
c = dijkstra(g,n,0)

#print(np.array(c) + 1)

ans = []
for i in range(1,n):
    if c[i] >= 0:
        ans.append(c[i]+1)
    else:
        print('No')
        exit()

print('Yes')
for i in range(len(ans)):
    print(ans[i])

#print(np.array(c)+1)


Fixed submission:
import queue
n, m = map(int, input().split())
g = [[] for _ in range(n+1)]

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

#print(g)

root = [0] * n
count = 0
q = queue.Queue()
q.put(0)
root[0] = 1
count += 1
while not q.empty():
    p = q.get()
    for i in g[p+1]:
        if root[i-1] <= 0:
            q.put(i-1)
            root[i-1] = p + 1
            count += 1
            #print(p,i,count,root)
            if count >= n:
                break


if count < n:
    print('No')
    exit()
else:
    print('Yes')
    for i in range(1,n):
        print(root[i])

Buggy python submission (verdict: Runtime Error):
import numpy as np
import heapq

def dijkstra_heapq(graph,node_count,start_index):
    #INF = np.sum(graph) + 1
    INF = 10**9+7
    node = [[INF,i] for i in range(node_count)]
    const_node = [[INF,-1] for i in range(node_count)]

    node[start_index][0] = 0
    heapq.heapify(node)

    print(const_node)

    while len(node) > 0:
        sub_dist,min_node_dex = heapq.heappop(node)
        const_node[min_node_dex][0] = sub_dist

        for i in range(len(node)):
            if g[min_node_dex][node[i][1]] > 0:
                    new_dist = sub_dist + g[min_node_dex][node[i][1]]
                    if new_dist < node[i][0]:
                        node[i][0] = new_dist
                        const_node[node[i][1]][1] = min_node_dex

        print(const_node)

    return const_node

def dijkstra(graph,node_count,start_index):
    INF = 10**9+7
    node = [INF] * node_count
    conf = [0] * node_count
    root = [-1] * node_count

    node[start_index] = 0
    count = 0
    while sum(conf) < node_count:

        change = False

        min_node_dex = -1
        min_node_val = INF
        for i in range(node_count):
            if conf[i] == 0:
                if node[i] < min_node_val:
                    min_node_val = node[i]
                    min_node_dex = i
        conf[min_node_dex] = 1
        for i in range(node_count):
            if conf[i] == 0:
                if g[min_node_dex][i] > 0:
                    new_dist = node[min_node_dex] + g[min_node_dex][i]
                    if new_dist < node[i]:
                        node[i] = new_dist
                        root[i] = min_node_dex
                        change = True

        #print(node)
        #print(conf)
        #print(root)
        count += 1
        if not change:
            break
        #if count >= 10:
        #    break
    return root

n, m = map(int, input().split())
r = []
g = np.zeros((n,n),dtype=np.int64)

for i in range(m):
    a, b = map(int, input().split())
    g[a-1][b-1] = 1
    g[b-1][a-1] = 1
    #r.append([a,b])

#c = dijkstra_heapq(g,n,0)
c = dijkstra(g,n,0)

#print(np.array(c) + 1)

ans = []
for i in range(1,n):
    if c[i] >= 0:
        ans.append(c[i]+1)
    else:
        print('No')
        exit()

print('Yes')
for i in range(len(ans)):
    print(ans[i])

#print(np.array(c)+1)


Fixed submission:
import queue
n, m = map(int, input().split())
g = [[] for _ in range(n+1)]

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

#print(g)

root = [0] * n
count = 0
q = queue.Queue()
q.put(0)
root[0] = 1
count += 1
while not q.empty():
    p = q.get()
    for i in g[p+1]:
        if root[i-1] <= 0:
            q.put(i-1)
            root[i-1] = p + 1
            count += 1
            #print(p,i,count,root)
            if count >= n:
                break


if count < n:
    print('No')
    exit()
else:
    print('Yes')
    for i in range(1,n):
        print(root[i])