n=int(input())
while (n!=0):
l=list(map(int,input().split()))
r=[0]*n
for i in range(n):
r[l[i]-1]=i+1
if l==r:
print("ambiguous")
else:
print("not ambiguous")
n=int(input())
could any body say why we have taken n=int(input()) again at down in permut2