Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())

routes = []
for i in range(m):
    x,y = map(int, input().split())
    routes.append([x-1,y-1])
    # routes[i] = routes[i] - [1,1] #道の番号をずらす

rooms = [0 for i in range(n)] # 行ったら1,まだなら0
marks = [0 for i in range(n)] # 部屋におく道標
roads = [0 for i in range(m)]
rooms_rate = [[0]] # １回目、２回目、３回目…に行ける部屋
rooms[0] = 1

turn = 0
for i in rooms_rate:
    newrate = []
    for j in rooms_rate[turn]: #turn回目に行ける部屋を調べる
        for k in range(m):
            if(roads[k] == 1):
                continue
            else:
                a = routes[k][0]
                b = routes[k][1]
            if (j == a and rooms[b] == 0):
                rooms[b] = 1
                marks[b] = a
                newrate.append(b)
                roads[k] = 1
            elif (j == b and rooms[a] == 0):
                rooms[a] = 1
                marks[a] = b
                newrate.append(a)
                roads[k] = 1
    rooms_rate.append(newrate)
    if (len(newrate) == 0):
        break
    turn = turn + 1


if(all(rooms) == True):
    print('Yes')
    for i in range(1,n):
        print(str(int(marks[i]) + 1))

else:
    print('No')

Fixed submission:
n,m = map(int, input().split())

routes = [[] for i in range(n)]
for i in range(m):
    x,y = map(int, input().split())
    routes[x-1].append(y-1)
    routes[y-1].append(x-1)


rooms = [0 for i in range(n)] # 行ったら1,まだなら0
marks = [0 for i in range(n)] # 部屋におく道標
rooms_rate = [[0]] # ０回目、１回目、２回目、３回目…に行ける部屋
rooms[0] = 1

turn = 0
for i in rooms_rate:
    newrate = []
    for j in rooms_rate[turn]: #(turn)回目に行けた部屋から行ける部屋を調べる
        for k in routes[j]: 
            if (rooms[k] == 0): #行ったことのない部屋なら
                rooms[k] = 1
                marks[k] = j # 道標をセット
                newrate.append(k)
    rooms_rate.append(newrate)
    if (len(newrate) == 0): #新しく行けなくなったら終わり
        break
    turn = turn + 1


if(all(rooms) == True):
    print('Yes')
    for i in range(1,n):
        print(str(int(marks[i]) + 1))

else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())

routes = []
for i in range(m):
    x,y = map(int, input().split())
    routes.append([x-1,y-1])
    # routes[i] = routes[i] - [1,1] #道の番号をずらす

rooms = [0 for i in range(n)] # 行ったら1,まだなら0
marks = [0 for i in range(n)] # 部屋におく道標
rooms_rate = [[0]] # １回目、２回目、３回目…に行ける部屋
rooms[0] = 1

turn = 0
for i in rooms_rate:
    newrate = []
    for j in rooms_rate[turn]: #turn回目に行ける部屋を調べる
        for k in range(m):
            a = routes[k][0]
            b = routes[k][1]
            if (j == a and rooms[b] == 0):
                rooms[b] = 1
                marks[b] = a
                newrate.append(b)
            elif (j == b and rooms[a] == 0):
                rooms[a] = 1
                marks[a] = b
                newrate.append(a)
    rooms_rate.append(newrate)
    if (len(newrate) == 0):
        break
    turn = turn + 1


if(all(rooms) == True):
    print('Yes')
    for i in range(1,n):
        print(str(int(marks[i]) + 1))

else:
    print('No')

Fixed submission:
n,m = map(int, input().split())

routes = [[] for i in range(n)]
for i in range(m):
    x,y = map(int, input().split())
    routes[x-1].append(y-1)
    routes[y-1].append(x-1)


rooms = [0 for i in range(n)] # 行ったら1,まだなら0
marks = [0 for i in range(n)] # 部屋におく道標
rooms_rate = [[0]] # ０回目、１回目、２回目、３回目…に行ける部屋
rooms[0] = 1

turn = 0
for i in rooms_rate:
    newrate = []
    for j in rooms_rate[turn]: #(turn)回目に行けた部屋から行ける部屋を調べる
        for k in routes[j]: 
            if (rooms[k] == 0): #行ったことのない部屋なら
                rooms[k] = 1
                marks[k] = j # 道標をセット
                newrate.append(k)
    rooms_rate.append(newrate)
    if (len(newrate) == 0): #新しく行けなくなったら終わり
        break
    turn = turn + 1


if(all(rooms) == True):
    print('Yes')
    for i in range(1,n):
        print(str(int(marks[i]) + 1))

else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())

routes = []
for i in range(m):
    route = list(map(int, input().split()))
    routes.append(route)
    routes[i] = routes[i] - [1,1] #道の番号をずらす

rooms = []
for i in range(n):
    rooms.append(0) # 行ったら1,まだなら0
marks = rooms # 部屋におく道標
roomsrate = [[0]] # １回目、２回目、３回目…に行ける部屋
rooms[0] = 1

turn = 0
for i in roomsrate:
    newrate = []
    for j in roomsrate[turn]: #turn回目に行ける部屋を調べる
        for k in range(m):
            a = int(routes[k][0])
            b = int(routes[k][1]) 
            if (j == a and int(rooms[b]) == 0):
                rooms[b] = 1
                marks[b] = a
                newrate.append(b)
            elif (j == b and int(rooms[a]) == 0):
                rooms[a] = 1
                marks[a] = b
                newrate.append(a)
    roomsrate.append(newrate)
    if (len(newrate) == 0):
        break
    turn = turn + 1


if(all(rooms) == True):
    print('Yes')
    for i in range(1,n):
        print(str(int(marks[i]) + 1))

else:
    print('No')

Fixed submission:
n,m = map(int, input().split())

routes = [[] for i in range(n)]
for i in range(m):
    x,y = map(int, input().split())
    routes[x-1].append(y-1)
    routes[y-1].append(x-1)


rooms = [0 for i in range(n)] # 行ったら1,まだなら0
marks = [0 for i in range(n)] # 部屋におく道標
rooms_rate = [[0]] # ０回目、１回目、２回目、３回目…に行ける部屋
rooms[0] = 1

turn = 0
for i in rooms_rate:
    newrate = []
    for j in rooms_rate[turn]: #(turn)回目に行けた部屋から行ける部屋を調べる
        for k in routes[j]: 
            if (rooms[k] == 0): #行ったことのない部屋なら
                rooms[k] = 1
                marks[k] = j # 道標をセット
                newrate.append(k)
    rooms_rate.append(newrate)
    if (len(newrate) == 0): #新しく行けなくなったら終わり
        break
    turn = turn + 1


if(all(rooms) == True):
    print('Yes')
    for i in range(1,n):
        print(str(int(marks[i]) + 1))

else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,m = map(int, input().split())

routes = []
for i in range(m):
    route = list(map(int, input().split()))
    routes.append(route)
    routes[i] = routes[i] - np.ones(2) #道の番号をずらす

rooms = np.zeros(n) # 行ってない部屋は0、行った部屋は1
marks = np.zeros(n) # 部屋におく道標
roomsrate = [[0]] # １回目、２回目、３回目…に行ける部屋
rooms[0] = 1

turn = 0
for i in roomsrate:
    newrate = []
    for j in roomsrate[turn]: #turn回目に行ける部屋を調べる
        for k in range(m):
            a = int(routes[k][0])
            b = int(routes[k][1]) 
            if (j == a and int(rooms[b]) == 0):
                rooms[b] = 1
                marks[b] = a
                newrate.append(b)
            elif (j == b and int(rooms[a]) == 0):
                rooms[a] = 1
                marks[a] = b
                newrate.append(a)
    roomsrate.append(newrate)
    if (len(newrate) == 0):
        break
    turn = turn + 1

if(np.all(rooms) == True):
    print('Yes')
    for i in range(1,n):
        print(str(int(marks[i]) + 1))

else:
    print('No')

Fixed submission:
n,m = map(int, input().split())

routes = [[] for i in range(n)]
for i in range(m):
    x,y = map(int, input().split())
    routes[x-1].append(y-1)
    routes[y-1].append(x-1)


rooms = [0 for i in range(n)] # 行ったら1,まだなら0
marks = [0 for i in range(n)] # 部屋におく道標
rooms_rate = [[0]] # ０回目、１回目、２回目、３回目…に行ける部屋
rooms[0] = 1

turn = 0
for i in rooms_rate:
    newrate = []
    for j in rooms_rate[turn]: #(turn)回目に行けた部屋から行ける部屋を調べる
        for k in routes[j]: 
            if (rooms[k] == 0): #行ったことのない部屋なら
                rooms[k] = 1
                marks[k] = j # 道標をセット
                newrate.append(k)
    rooms_rate.append(newrate)
    if (len(newrate) == 0): #新しく行けなくなったら終わり
        break
    turn = turn + 1


if(all(rooms) == True):
    print('Yes')
    for i in range(1,n):
        print(str(int(marks[i]) + 1))

else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,m = map(int, input().split())

routes = []
for i in range(m):
    route = list(map(int, input().split()))
    routes.append(route)

for i in range(m):
    routes[i] = routes[i] - np.ones(2) #道の番号をずらす

rooms = np.zeros(n) # 行ってない部屋は0、行った部屋は1
marks = np.zeros(n) # 部屋におく道標
roomsrate = [[0]] # １回目、２回目、３回目…に行ける部屋
rooms[0] = 1
marks[0] = 1

turn = 0
for i in roomsrate:
    newrate = []
    for j in roomsrate[turn]: #turn回目に行ける部屋を調べる
        for k in range(m):
            a = int(routes[k][0])
            b = int(routes[k][1]) 
            if (j == a or j == b):
                if (int(rooms[b]) == 0):
                    rooms[b] = 1
                    marks[b] = a
                    newrate.append(b)
                elif (int(rooms[a]) == 0):
                    rooms[a] = 1
                    marks[a] = b
                    newrate.append(a)
    roomsrate.append(newrate)
    if (len(newrate) == 0):
        break
    turn = turn + 1

if(np.all(rooms) == True):
    print('Yes')
    for i in range(1,n):
        print(str(int(marks[i]) + 1))

else:
    print('No')

Fixed submission:
n,m = map(int, input().split())

routes = [[] for i in range(n)]
for i in range(m):
    x,y = map(int, input().split())
    routes[x-1].append(y-1)
    routes[y-1].append(x-1)


rooms = [0 for i in range(n)] # 行ったら1,まだなら0
marks = [0 for i in range(n)] # 部屋におく道標
rooms_rate = [[0]] # ０回目、１回目、２回目、３回目…に行ける部屋
rooms[0] = 1

turn = 0
for i in rooms_rate:
    newrate = []
    for j in rooms_rate[turn]: #(turn)回目に行けた部屋から行ける部屋を調べる
        for k in routes[j]: 
            if (rooms[k] == 0): #行ったことのない部屋なら
                rooms[k] = 1
                marks[k] = j # 道標をセット
                newrate.append(k)
    rooms_rate.append(newrate)
    if (len(newrate) == 0): #新しく行けなくなったら終わり
        break
    turn = turn + 1


if(all(rooms) == True):
    print('Yes')
    for i in range(1,n):
        print(str(int(marks[i]) + 1))

else:
    print('No')

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,m = map(int, input().split())

routes = []
for i in range(m):
    route = list(map(int, input().split()))
    routes.append(route)

for i in range(m):
    routes[i] = routes[i] - np.ones(2) #道の番号をずらす

rooms = np.zeros(n) # 行ってない部屋は0、行った部屋は1
marks = np.zeros(n) # 部屋におく道標
roomsrate = [[0]] # １回目、２回目、３回目…に行ける部屋
rooms[0] = 1
marks[0] = 1

for i in range roomsrate:
    newrate = []
    for j in range roomsrate[i]: # i回目に行ける部屋を調べる
        for k in range(m):
            a = int(routes[k][0])
            b = int(routes[k][1]) 
            if (j == a or j == b):
                if (int(rooms[b]) == 0):
                    rooms[b] = 1
                    marks[b] = a
                    newrate.append(b)
                elif (int(rooms[a]) == 0):
                    rooms[a] = 1
                    marks[a] = b
                    newrate.append(a)
    roomsrate.append(newrate)
    if(newrate == [])
    break


if(np.all(rooms) == True):
    print('Yes')
    for i in range(1,n):
        print(str(int(marks[i]) + 1))

else:
    print('No')

Fixed submission:
n,m = map(int, input().split())

routes = [[] for i in range(n)]
for i in range(m):
    x,y = map(int, input().split())
    routes[x-1].append(y-1)
    routes[y-1].append(x-1)


rooms = [0 for i in range(n)] # 行ったら1,まだなら0
marks = [0 for i in range(n)] # 部屋におく道標
rooms_rate = [[0]] # ０回目、１回目、２回目、３回目…に行ける部屋
rooms[0] = 1

turn = 0
for i in rooms_rate:
    newrate = []
    for j in rooms_rate[turn]: #(turn)回目に行けた部屋から行ける部屋を調べる
        for k in routes[j]: 
            if (rooms[k] == 0): #行ったことのない部屋なら
                rooms[k] = 1
                marks[k] = j # 道標をセット
                newrate.append(k)
    rooms_rate.append(newrate)
    if (len(newrate) == 0): #新しく行けなくなったら終わり
        break
    turn = turn + 1


if(all(rooms) == True):
    print('Yes')
    for i in range(1,n):
        print(str(int(marks[i]) + 1))

else:
    print('No')