NZEC runtime error in python 3

t = int(input())
l = []

MAX = 100

prime_num = [1] * (MAX + 1)

prime_num[0] = 0
prime_num[1] = 0

for i in range(2,MAX+1):
    if prime_num[i] == 1:
        val = i
        for j in range(2*val, MAX+1 , val):
            prime_num[j] = 0
            
while t:
    m , n = [int(i) for i in input().split(' ')]
    if m < 2:
        m = 2
    for i in range(m,n+1):
        if prime_num[i] == 1:
            print(i) 
    print('')    
    t -= 1

your code works well only if n is less than 100.see the constraints,n can be upto 10^9.Here you need to apply segmented sieve of erasthones instead of sieve of erasthones.If you are not aware of segmented sieve got through this link https://www.hackerearth.com/practice/notes/number-theory-iii/

The root of this problem is that, given the memory limit, you cannot declare an array of size 10^9.

This is bound to give you a runtime error. Either a SIGSEV or NZEC error.

try:
t=int(input())
out=[]
x=0
for i in range(t):
N,A,B,K=map(int,input().split())
for j in range(N):
if((j%A==0) and (j%B==0)):
continue
elif((j%A==0) or (j%B==0)):
x=x+1
else:
continue
if x>=K:
out.append(“Win”)
else:
out.append(“Lose”)
for i in range(t):
print(out[i])
except EOFError:
Exit