NZEC Runtime error Python

from pip._vendor.distlib.compat import raw_input

t = int(raw_input())

for i in range(t):
n = int(raw_input())
c = 0
if n == 0:
exit()
else:
lis1 = list(map(int, raw_input().split()))
lis2 = []
for j in range(1, n+1):
p = lis1.index(j)
lis2.append(p+1)
for j in range(n):
if lis1[j] == lis2[j]:
c = c + 1

if c == n:
    print("ambiguous")
else:
    print("not ambiguous")

posting this in a format that one can read will provide you some answers.