April cookoff 2021

Hi All,

I got a problem while solving question code OROFAND .
I am getting NZEC Error. I don’t know why.
Can you guys please check and tell where am I getting error.
The code is attached below.

T = int(input())
while T:
    N,Q = map(int,input().split(' ',2))
    A = list(map(int,input().split()))
    ANDOP = []
    for i in range(len(A)):
        ANDOP.append(A[i])
    for j in range(len(A)):
        if j != (len(A)-1):
            AND = A[j]&A[j+1]
            ANDOP.append(AND)
    val = A[0]
    for i in range(len(A)):
        if i != (len(A)-1):
            val &= A[i]
    ANDOP.append(val)
    val = A[0]
    for i in range(len(ANDOP)):
        if i != (len(ANDOP)-1):
            val |= ANDOP[i] 
    OROP = val
    print(OROP)
    while Q:
        X,V = map(int,input().split(' ',2))
        A[X-1] = V 
        ANDOP = []
        for i in range(len(A)):
            ANDOP.append(A[i])
        for j in range(len(A)):
            if j != (len(A)-1):
                AND = A[j]&A[j+1]
                ANDOP.append(AND)
        val = A[0]
        for i in range(len(A)):
            if i != (len(A)-1):
                val &= A[i]
        ANDOP.append(val)
        val = A[0]
        for i in range(len(ANDOP)):
            if i != (len(ANDOP)-1):
                val |= ANDOP[i] 
        OROP = val
        print(OROP)
        Q -= 1
    T -= 1

Kindly provide a link to your submission or paste your code in between a pair of 3 backticks (`).

Are you trying to run without providing custom input?

yes