Buggy python submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

def get_path(start, goal, pred):
    return get_path_row(start, goal, pred[start])
    
def get_path_row(start, goal, pred_row):
    path = []
    i = goal
    while i != start and i >= 0:
        path.append(i)
        i = pred_row[i]
    if i < 0:
        return []
    path.append(i)
    return path[::-1]

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

graph=np.zeros((n,n))

for i in range(m):
    graph[a[i]-1][b[i]-1] = 1
    graph[b[i]-1][a[i]-1] = 1

d,p=shortest_path(graph,return_predecessors=True)
flag = 0
ans = []
for i in range(1, n):
    michi = get_path(0, i, p)
    if len(michi) == 0:
        print('No')
        flag = 1
        break
    else:
        ans.append(michi[-2]+1)
        print(ans)
if flag == 0:
    print('Yes')
    for i in ans:
        print(i)

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

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

from collections import deque

def bfs(u):
    queue = deque([u])
    d=[-1]*n
    pre=[-1]*n
    d[u]=0
    while queue:
        v=queue.popleft()
        for i in g[v]:
            if d[i] is -1:
                if pre[i] == -1:
                    pre[i]=v
                d[i]=d[v]+1
                queue.append(i)
    return d,pre
d,pre=bfs(0)
print('Yes')

for i in range(n):
    if i==0:
        continue
    print(pre[i]+1)

Buggy python submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

def get_path(start, goal, pred):
    return get_path_row(start, goal, pred[start])
    
def get_path_row(start, goal, pred_row):
    path = []
    i = goal
    while i != start and i >= 0:
        path.append(i)
        i = pred_row[i]
    if i < 0:
        return []
    path.append(i)
    return path[::-1]

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

graph=np.zeros((n,n))

for i in range(m):
    graph[a[i]-1][b[i]-1] = 1
    graph[b[i]-1][a[i]-1] = 1

d,p=shortest_path(graph,return_predecessors=True)

for i in range(1,n):
    for j in range(i,n):
        if graph[i][j] == np.inf:
            print('No')
            break
        if i == n - 1 and j == n -1:
            print('Yes')
            for i in range(1,n):
                michi= get_path(0,i,p)
                print(michi[-2]+1)


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

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

from collections import deque

def bfs(u):
    queue = deque([u])
    d=[-1]*n
    pre=[-1]*n
    d[u]=0
    while queue:
        v=queue.popleft()
        for i in g[v]:
            if d[i] is -1:
                if pre[i] == -1:
                    pre[i]=v
                d[i]=d[v]+1
                queue.append(i)
    return d,pre
d,pre=bfs(0)
print('Yes')

for i in range(n):
    if i==0:
        continue
    print(pre[i]+1)

Buggy python submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

def get_path(start, goal, pred):
    return get_path_row(start, goal, pred[start])
    
def get_path_row(start, goal, pred_row):
    path = []
    i = goal
    while i != start and i >= 0:
        path.append(i)
        i = pred_row[i]
    if i < 0:
        return []
    path.append(i)
    return path[::-1]

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

graph=np.zeros((n,n))

for i in range(m):
    graph[a[i]-1][b[i]-1] = 1
    graph[b[i]-1][a[i]-1] += 1

d,p=shortest_path(graph,return_predecessors=True)

for i in range(1,n):
    for j in range(i,n):
        if graph[i][j] == np.inf:
            print('No')
            break
        if i == n - 1 and j == n -1:
            print('Yes')
            for i in range(1,n):
                michi= get_path(0,i,p)
                print(michi[-2]+1)

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

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

from collections import deque

def bfs(u):
    queue = deque([u])
    d=[-1]*n
    pre=[-1]*n
    d[u]=0
    while queue:
        v=queue.popleft()
        for i in g[v]:
            if d[i] is -1:
                if pre[i] == -1:
                    pre[i]=v
                d[i]=d[v]+1
                queue.append(i)
    return d,pre
d,pre=bfs(0)
print('Yes')

for i in range(n):
    if i==0:
        continue
    print(pre[i]+1)

Buggy python submission (verdict: Runtime Error):
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
n,m = map(int, input().split())
a=[]
b=[]
for i in range(m):
    aa,bb=map(int,input().split())
    a.append(aa)
    b.append(bb)

graph=np.zeros((n,n))

for i in range(m):
    graph[a[i]-1][b[i]-1] = 1
    graph[b[i]-1][a[i]-1] += 1

d,p=shortest_path(graph,return_predecessors=True)
print(d)
print(p)

def get_path(start, goal, pred):
    return get_path_row(start, goal, pred[start])
    
def get_path_row(start, goal, pred_row):
    path = []
    i = goal
    while i != start and i >= 0:
        path.append(i)
        i = pred_row[i]
    if i < 0:
        return []
    path.append(i)
    return path[::-1]

for i in range(1,m):
    for j in range(i,m):
        if graph[i][j] == np.inf:
            print('No')
            break
        if i == m - 1 and j == m -1:
            print('Yes')
            for i in range(1,n):
                michi= get_path(0,i,p)
                print(michi[-2]+1)

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

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

from collections import deque

def bfs(u):
    queue = deque([u])
    d=[-1]*n
    pre=[-1]*n
    d[u]=0
    while queue:
        v=queue.popleft()
        for i in g[v]:
            if d[i] is -1:
                if pre[i] == -1:
                    pre[i]=v
                d[i]=d[v]+1
                queue.append(i)
    return d,pre
d,pre=bfs(0)
print('Yes')

for i in range(n):
    if i==0:
        continue
    print(pre[i]+1)