Buggy python submission (verdict: Runtime Error):
import math
import collections
from collections import defaultdict

N = int(input())
iwa = []
mod = 10**9+7
cnt = 0
for i in range(N):
    a, b = map(int,input().split())
    if a == 0 and b == 0:
        cnt = 1
        continue
    elif b == 0:
        iwa.append((1,0))
    elif a == 0:
        iwa.append((0,1))
    elif b > 0:
        c = math.gcd(a,b)
        iwa.append((a/c, b/c))#bは正
    else:
        c = math.gcd(a,b)
        iwa.append((-a/c, -b/c))#bは正
        
S = set(iwa)
I = collections.Counter(iwa)
#print(I)
jdg = defaultdict(int)

ans = 1
for i in S:
    if jdg[i] == 1:
        continue
    elif i == (1,0) or i == (0,1):
        k = I[(1,0)]
        l = I[(0,1)]
        if min(k,l) == 0:
            ans *= pow(2,max(l,k),mod)
        else:
            ans *= (pow(2,l,mod)-1) + (pow(2,k,mod)-1)+1
        jdg[(1,0)] = 1
        jdg[(0,1)] = 1
    else:
        k = I[i]
        a, b = i
        if a < 0:
            l = I[(b,-a)]
            jdg[(b, -a)] = 1
        else:
            l = I[(-b,a)]
            jdg[(-b,a)] = 1
        if min(l,k) == 0:
            ans *= pow(2,max(l,k),mod)
        else:
            ans *= (pow(2,l,mod)-1) + (pow(2,k,mod)-1)+1
        jdg[i] = 1
print(ans+cnt-1)

Fixed submission:
from collections import deque
    
def bfs(graph,start): #def bfs(graph,start,limit): 
    dist = [-1] * (N)
    ans = [-1] *(N)
    dist[start]= 0
    q = deque([start])
    cnt = 0
    while q:
        x = q.popleft()
        for i in graph[x]:
            #if dist[x] >= limit:
            #    break
            if dist[i] == -1:
                dist[i] = dist[x] + 1
                ans[i] = x+1
                q.append(i)
    return dist, ans

N,M  = map(int,input().split())# 頂点数
X = [[] for i in range(N)] #辺リスト

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

dist,ans = bfs(X,0)
#print(dist,ans)
if -1 in dist:
    print("No")
else:
    print("Yes")
    for i in range(1,N):
        print(ans[i])

Buggy python submission (verdict: Runtime Error):
from collections import deque
    
def bfs(graph,start): #def bfs(graph,start,limit): 
    dist = [-1] * (N)
    ans = [-1] *(N)
    dist[start]= 0
    q = deque([start])
    cnt = 0
    while q:
        x = q.popleft()
        for i in graph[x]:
            #if dist[x] >= limit:
            #    break
            if dist[i] == -1:
                dist[i] = dist[x] + 1
                ans[i] = x+1
                q.append(i)
    return dist, ans

N,M  = map(int,input().split())# 頂点数
X = [[] for i in range(M)] #辺リスト
P = [[] for i in range(M)]
for i in range(M):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

dist,ans = bfs(X,0)
#print(dist,ans)
if -1 in dist:
    print("No")
else:
    print("Yes")
    for i in range(1,N):
        print(ans[i])

Fixed submission:
from collections import deque
    
def bfs(graph,start): #def bfs(graph,start,limit): 
    dist = [-1] * (N)
    ans = [-1] *(N)
    dist[start]= 0
    q = deque([start])
    cnt = 0
    while q:
        x = q.popleft()
        for i in graph[x]:
            #if dist[x] >= limit:
            #    break
            if dist[i] == -1:
                dist[i] = dist[x] + 1
                ans[i] = x+1
                q.append(i)
    return dist, ans

N,M  = map(int,input().split())# 頂点数
X = [[] for i in range(N)] #辺リスト

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

dist,ans = bfs(X,0)
#print(dist,ans)
if -1 in dist:
    print("No")
else:
    print("Yes")
    for i in range(1,N):
        print(ans[i])