Ambiguous Permutations

No attempts yetTime limit1sMemory limit128 MB

Problem

Some programming contest problems are really tricky: not only do they require a different output format from what you might expect, but the sample output does not even reveal the difference. As an example, let us look at permutations.

A permutation of the integers $1$ to $n$ is an ordering of these integers. The natural way to represent a permutation is to list the integers in this order. With $n = 5$, a permutation might look like 2, 3, 4, 5, 1.

However, there is another way to represent a permutation: you build a list of numbers in which the $i$-th number is the position of the integer $i$ within the permutation. Let us call this second representation the inverse permutation. The inverse permutation of the sequence above is 5, 1, 2, 3, 4.

An ambiguous permutation is a permutation that cannot be distinguished from its inverse permutation, that is, a permutation that is exactly equal to its own inverse. For example, the permutation 1, 4, 3, 2 is ambiguous because its inverse permutation is the same. Write a program that decides whether a given permutation is ambiguous or not.

Input

The input contains several test cases.

The first line of each test case contains an integer $n$ ($1 \le n \le 100000$). The next line contains a permutation of the integers $1$ to $n$, with exactly one space between consecutive integers. You may assume that every integer between $1$ and $n$ appears exactly once in the permutation.

The last test case is followed by a line containing $0$.

Output

For each test case, print ambiguous if the permutation is ambiguous, or not ambiguous otherwise, each on its own line.