SPOJ PERMUT2 - Ambiguous Permutations