The Addition Game
Time limit1sMemory limit256 MB
Decide whether two permutations of 1 to n add up to the given sequence modulo n.
- Level
Medium7 of 10
- Topics
- Math, Combinatorics
- Solved
- No attempts yet
Problem
Alan works at a company that specialises in computer security. He designed a public key cryptosystem in which the private key is a pair of permutations and of . The public key is then given by for . The notation means that and leave the same remainder when divided by .
Take with
- ,
- .
The public key is then . For instance , and each of and contains every number of exactly once.
Alan's coworkers doubt that the system is secure, since any private key matching the public key breaks it. Help them out. Given and a sequence , decide whether there are permutations and of with for every .
Input
The first line contains the length of the sequence ().
The second line contains integers ().
Output
Print possible if permutations and with the property above exist, and impossible otherwise.