Why is this code giving error? Kindly help

#code -

import sys
sys.setrecursionlimit(200001)
def sol(idx,n,l,curPar,dp):
	if(idx==n):
		if(curPar&1):
			return 1
		return 0
	if(dp[idx][curPar]!=-1):
		return dp[idx][curPar]
	u,v=l[idx]
	ans=0
	if((curPar+u)&1):
		ans+=sol(idx+1,n,l,1,dp)
	else:
		ans+=sol(idx+1,n,l,0,dp)
	if((curPar+v)&1):
		ans+=sol(idx+1,n,l,1,dp)
	else:
		ans+=sol(idx+1,n,l,0,dp)
	ans%=1000000007
	dp[idx][curPar]=ans
	return dp[idx][curPar] 
 
# Solver function
def solve():
	n=int(input())
	l=[]
	for i in range(n):
		u,v=map(int,input().split())
		l.append([u,v])
	dp=[[-1 for i in range(2)] for i in range(n)]
	print(sol(0,n,l,0,dp))
	
# Main 
for _ in range(1):
	#prl(f"Case #{_+1}:")
	solve()

#error - /bin/run.sh: line 3: 14 Segmentation fault (core dumped) python3 script.py