Buggy python submission (verdict: Runtime Error):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

n,m = imap()
ab = np.array([iarr() for i in range(m)])
g = adj(n+1)
for i in range(n):
    aa,bb = ab[i][0],ab[i][1]
    g[aa].append(bb)
    g[bb].append(aa)

dep = iarr(n+1)
dep[1] = 1
q = col.deque([1])
route = iarr(n+1)
while q:
    now = q.popleft()
    for next in g[now]:
        if dep[next]: continue
        else:
            q.append(next)
            dep[next] = dep[now]+1
            route[next] = now

print("Yes")
for ans in route[2:]: print(ans)






Fixed submission:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

#標準入力
n,m = imap()
ab = np.array([iarr() for i in range(m)])
a,b = ab.T[0]-1, ab.T[1]-1

#隣接行列はnumpy使うな
g = [[] for i in range(n)]
for aa,bb in zip(a,b):
    g[aa].append(bb)
    g[bb].append(aa)


anss = [0]*n
know = [0]*n; know[0] = 1
q = col.deque([0])
while q:
    now = q.popleft()
    for next in g[now]:
        if know[next]: continue
        else: know[next] = 1; anss[next] = now; q.append(next)

print('Yes')
for ans in anss[1:]: print(ans+1)

Buggy python submission (verdict: Runtime Error):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
def adj(n): return [[] for _ in range(n)]

n,m = imap()
ab = np.array([iarr() for i in range(m)])
a,b = ab.T[0]-1, ab.T[1]-1
adj = adj(n)
for i in range(n):
    aa,bb = a[i],b[i]
    adj[aa].append(bb)
    adj[bb].append(aa)

dep = iarr(n)
q = col.deque([0])
route = iarr(n)
while q:
    now = q.popleft()
    for next in adj[now]:
        if dep[next]: continue
        else:
            q.append(next)
            dep[next] = dep[now]+1
            route[next] = now

print("Yes")
for ans in route[1:]: print(ans+1)





Fixed submission:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

#標準入力
n,m = imap()
ab = np.array([iarr() for i in range(m)])
a,b = ab.T[0]-1, ab.T[1]-1

#隣接行列はnumpy使うな
g = [[] for i in range(n)]
for aa,bb in zip(a,b):
    g[aa].append(bb)
    g[bb].append(aa)


anss = [0]*n
know = [0]*n; know[0] = 1
q = col.deque([0])
while q:
    now = q.popleft()
    for next in g[now]:
        if know[next]: continue
        else: know[next] = 1; anss[next] = now; q.append(next)

print('Yes')
for ans in anss[1:]: print(ans+1)