Buggy python submission (verdict: Runtime Error):
import sys 
from collections import defaultdict 
 
class Graph: 
 
    def __init__(self): 
        global n
        self.graph = defaultdict(list) 
        self.parent = [None for i in range(0,n) ]
    def addEdge(self,u,v): 
        self.graph[u].append(v) 
    def BFS(self, s): 
        visited = [False] * (len(self.graph)) 
  
        queue = [] 
        queue.append(s) 
        visited[s] = True
  
        while queue: 
            s = queue.pop(0) 
            # print (s, end = " ") 
            for i in self.graph[s]: 
                
                if visited[i] == False: 
                    self.parent[i]=s+1
                    queue.append(i) 
                    visited[i] = True


[n,m]=[int(i) for i in input().split(' ')]
g = Graph() 
for i in range(0,m):
    [a,b]=[int(i)-1 for i in input().split(' ')]
    g.addEdge(a,b)
g.BFS(0)
flag=0
for i in range(1,n):
    if g.parent[i]==None:
        print('NO')
        flag=1
        break
if flag==0:
    print('YES')
    for i in range(1,n):
        print(g.parent[i])
        # 7

Fixed submission:
import sys 
from collections import defaultdict 
 
class Graph: 
 
    def __init__(self): 
        global n
        self.graph = defaultdict(list) 
        self.parent = [None for i in range(0,n+1)]
    def addEdge(self,u,v): 
        self.graph[u].append(v) 
    def BFS(self, s): 
        visited = [False] * (len(self.graph)+1) 
        queue = [] 
        queue.append(s)   
        while queue: 
            s = queue.pop(0) 
            
            # print (s, end = " ") 
            for i in self.graph[s]: 
                
                if visited[i] == False: 
                    self.parent[i]=s
                    queue.append(i) 
                    visited[i]=True
            

[n,m]=[int(i) for i in input().split(' ')]
g = Graph() 
for i in range(0,m):
    [a,b]=[int(i) for i in input().split(' ')]
    g.addEdge(a,b)
    g.addEdge(b,a)
# print(g.graph)
g.BFS(1)
flag=0
for i in range(2,n+1):
    if g.parent[i]==None:
        print('No')
        flag=1
        break

if flag==0:
    print('Yes')
    for i in range(2,n+1):
        print(g.parent[i])
        9

Buggy python submission (verdict: Runtime Error):
import sys 
from collections import defaultdict 
 
class Graph: 
 
    def __init__(self): 
        global n
        self.graph = defaultdict(list) 
        self.parent = [None for i in range(0,n) ]
    def addEdge(self,u,v): 
        self.graph[u].append(v) 
    def BFS(self, s): 
        visited = [False] * (len(self.graph)) 
  
        queue = [] 
        queue.append(s) 
        visited[s] = True
  
        while queue: 
            s = queue.pop(0) 
            # print (s, end = " ") 
            for i in self.graph[s]: 
                
                if visited[i] == False: 
                    self.parent[i]=s+1
                    queue.append(i) 
                    visited[i] = True


[n,m]=[int(i) for i in input().split(' ')]
g = Graph() 
for i in range(0,m):
    [a,b]=[int(i)-1 for i in input().split(' ')]
    g.addEdge(a,b)
g.BFS(0)
flag=0
for i in range(1,n):
    if g.parent[i]==None:
        print('NO')
        flag=1
        break
if flag==0:
    print('YES')
    for i in range(1,n):
        print(g.parent[i])
        # 7

Fixed submission:
import sys 
from collections import defaultdict 
 
class Graph: 
 
    def __init__(self): 
        global n
        self.graph = defaultdict(list) 
        self.parent = [None for i in range(0,n+1)]
    def addEdge(self,u,v): 
        self.graph[u].append(v) 
    def BFS(self, s): 
        visited = [False] * (len(self.graph)+1) 
        queue = [] 
        queue.append(s)   
        while queue: 
            s = queue.pop(0) 
            
            # print (s, end = " ") 
            for i in self.graph[s]: 
                
                if visited[i] == False: 
                    self.parent[i]=s
                    queue.append(i) 
                    visited[i]=True
            

[n,m]=[int(i) for i in input().split(' ')]
g = Graph() 
for i in range(0,m):
    [a,b]=[int(i) for i in input().split(' ')]
    g.addEdge(a,b)
    g.addEdge(b,a)
# print(g.graph)
g.BFS(1)
flag=0
for i in range(2,n+1):
    if g.parent[i]==None:
        print('No')
        flag=1
        break

if flag==0:
    print('Yes')
    for i in range(2,n+1):
        print(g.parent[i])
        9