Buggy python submission (verdict: Runtime Error):
from collections import deque
def main():
  n,m=map(int,input().split())
  e=[[]for _ in range(n)]
  for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    e[a].appned(b)
    e[b].append(a)
  ans=[-1]*n
  ans[0]="Yes"
  dq=deque([0])
  while dq:
    g=dq.popleft()
    for v in e[g]:
      if ans[v]==-1:
        ans[v]=g+1
        dq.append(v)
  print(*ans)
main()  


Fixed submission:
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()

Buggy python submission (verdict: Runtime Error):
from collections import deque
def main():
  n,m=map(int,input().split())
  e=[[]for _ in range(n)]
  for _ in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    e[a].appned(b)
    e[b].append(a)
  ans=[-1]*n
  dq=deque([0])
  while dq:
    g=dq.popleft()
    for v in e[g]:
      if ans[v]==-1:
        ans[v]=g+1
        dq.append(v)
  print(*ans[1:])
main()  

Fixed submission:
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()

Buggy python submission (verdict: Time Limit Exceeded):
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[]*n for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)
    
    ans=[-1]*(n)
    goal=deque([0])
    while (-1 in ans):
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()
    


Fixed submission:
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()

Buggy python submission (verdict: Time Limit Exceeded):
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[]*n for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)
    
    ans=[-1]*(n)
    goal=deque([0])
    while (-1 in ans):
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()
    


Fixed submission:
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()

Buggy python submission (verdict: Runtime Error):
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[]*n for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)
    
    ans=[-1]*(n-1)
    goal=deque([0])
    while (-1 in ans):
        g=goal.popleft()
        for i in edge[g]:
            if ans[i-1]==-1:
                ans[i-1]=g+1
                goal.append(i)
    yes()
    for i in ans:print(i)
main()
    


Fixed submission:
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()

Buggy python submission (verdict: Time Limit Exceeded):
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
        
    n,m=LI()
    edge=[[]*n for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)
    # print(edge)
    
    ans=[-1]*n
    goal=deque([0])
    while (-1 in ans):
        g=goal.popleft()
    
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
                
    
    
    # goal=deque([0])
    # while (-1 in ans):
    #     g=goal.popleft()
    #     for i,v in enumerate(edge):
    #         if v==-1:continue
    #         if g in v:
    #             ans[i]=g+1
    #             edge[i]=-1
    #             goal.append(i)
    
    if (-1 in ans):
        no()
        exit()
        
    yes()
    for i in ans[1:]:
        print(i)
main()
    


Fixed submission:
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()

Buggy python submission (verdict: Time Limit Exceeded):
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque
n,m=LI()
edge=[[]*n for i in range(n)]
for i in range(m):
    a,b=LI()
    a-=1;b-=1
    edge[a].append(b)
    edge[b].append(a)
# print(edge)

ans=[-1]*n
goal=deque([0])
while (-1 in ans):
    g=goal.popleft()
    # print(ans)
    for i in edge[g]:
        if ans[i]==-1:
            ans[i]=g+1
            goal.append(i)
            


# goal=deque([0])
# while (-1 in ans):
#     g=goal.popleft()
#     for i,v in enumerate(edge):
#         if v==-1:continue
#         if g in v:
#             ans[i]=g+1
#             edge[i]=-1
#             goal.append(i)

if (-1 in ans):
    no()
    exit()
    
yes()
for i in ans[1:]:
    print(i)



Fixed submission:
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()

Buggy python submission (verdict: Time Limit Exceeded):
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque
n,m=LI()
edge=[[]*n for i in range(n)]
for i in range(m):
    a,b=LI()
    a-=1;b-=1
    edge[a].append(b)
    edge[b].append(a)

ans=[-1]*n
goal=deque([0])
while (-1 in ans):
    g=goal.popleft()
    for i,v in enumerate(edge):
        if v==-1:continue
        if g in v:
            ans[i]=g+1
            edge[i]=-1
            goal.append(i)

if (-1 in ans):
    no()
    exit()
yes()
for i in ans[1:]:
    print(i)



Fixed submission:
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()

Buggy python submission (verdict: Time Limit Exceeded):
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque
n,m=LI()
edge=[[]*n for i in range(n)]
for i in range(m):
    a,b=LI()
    a-=1
    b-=1
    edge[a].append(b)
    edge[b].append(a)
# print(edge)

ans=[-1]*n
goal=deque([0])
while goal:
    if -1 not in ans:break
    g=goal.popleft()
    for i in range(n):
        v=edge[i]
        if g in v:
            ans[i]=g
            edge[i].clear()
            goal.append(i)

if -1 in ans:
    no()
    exit()
yes()
for i in ans[1:]:
    print(i+1)



Fixed submission:
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()

Buggy python submission (verdict: Time Limit Exceeded):
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque
n,m=LI()
edge=[[]*n for i in range(n)]
for i in range(m):
    a,b=LI()
    a-=1
    b-=1
    edge[a].append(b)
    edge[b].append(a)
# print(edge)

ans=[-1]*n
goal=deque([0])
while goal:
    g=goal.popleft()
    for i in range(n):
        v=edge[i]
        if g in v:
            ans[i]=g
            edge[i].clear()
            goal.append(i)

if -1 in ans:
    no()
    exit()
yes()
for i in ans[1:]:
    print(i+1)



Fixed submission:
def LI():return list(map(int,input().split()))
def yes():print("Yes")
def no():print("No")
from collections import deque

def main():
    n,m=LI()
    edge=[[] for i in range(n)]
    for i in range(m):
        a,b=LI()
        a-=1;b-=1
        edge[a].append(b)
        edge[b].append(a)    
    ans=[-1]*(n)
    goal=deque([0])
    while goal:
        g=goal.popleft()
        for i in edge[g]:
            if ans[i]==-1:
                ans[i]=g+1
                goal.append(i)
    yes()
    print(*ans[1:])
main()