SPOJ PERMUT2

379. Ambiguous Permutations
http://www.spoj.pl/problems/PERMUT2/

Summary
Identify whether the inverse permutation of a given permutation of digits is ambiguous.

Explanation
The inverse permutation is one where the i-th number is the position of the integer i in the permutation. It is ambiguous if it is identical to the normal representation of the permutation. For example, if { 2, 3, 4, 5, 1 } is a permutation, then it's inverse is { 5, 1, 2, 3, 4 } and in this case is not ambiguous.

Implementation
Plenty of time is allowed for this problem. A brute force comparison of one array with its inverse will satisfy the judge.

Input
The first line of the input is an integer $$1 \le n \le 100000$$ representing the length of the permutation to follow. The next line contains $$n$$ integers representing the permutation. More test cases may follow. The input is terminated by a single 0.  4 1 4 3 2 5 2 3 4 5 1 1 1 0 

Output
 ambiguous not ambiguous ambiguous 