I was getting Runtime error(NZEC) when I was submitting my solution for problem ARRT although it was running fine for sample test cases and other custom test cases…

My code:

```
def minSeq(A, B, n):
poss=[]
for k in range(n):
if 2*n -2 +A[0]+k in B:
p=2*n -2 +A[0]+k
poss.append(p)
if n-2+A[0]+k in B:
p=n-2+k+A[0]
poss.append(p)
if len(poss)>0:
break
if A[0]-n-1-k in B:
p=A[0]-n-1-k
if A[0]-1-k in B:
p=A[0]-n-1-k
if len(poss)>0:
break
i = B.index(poss[0])
fL=[]
for j in range(n):
fL.append((A[j]+B[(j+i)%n])%n)
fL2=[]
if(len(poss)==2):
i2 = B.index(poss[1])
fL2.append((A[j]+B[(j+i)%n])%n)
return min(fL, fL2) if fL2 else fL
t=int(input())
ans=[]
for _ in range(t):
n=int(input())
if n==0:
break;
A=[int(x) for x in input().split()]
B=[int(x) for x in input().split()]
ans.append(minSeq(A, B ,n))
for a in ans:
for _a in a:
print(_a,end=' ')
print()
```