Affine Cipher
A cipher process consists in change each symbol of a message to another symbol from the same alphabet used in the original message, in the way to has one by one correspondence to each other. It means that two different symbols can not be replaced by the same symbol.
An Affine cipher consists in suppose some symbols of a size alphabet as numbers of an interval [..]. Two positive numbers and are chosen. To cipher a symbol is necessary to multiply its position value on the alphabet by and the number needs to be added to the result of this multiplication. In the end, the result will be the position of the symbol that will replace the original in the sequence. If this new position does not correspond to a valid position inside the size of the alphabet, it supposes that the alphabet will be repeated many times on the right, in the way to have all estimated positions.
For example, suppose an alphabet which its size is and and . To cipher any symbol from this alphabet is necessary to extend the alphabet to the right by times, as shown below:

Figure 1
In this cipher, the symbol is ciphered to the symbol because and the symbol in position is .
Need to be noted that not all Affine cipher is valid. A poorly made cipher can not produce a one-by-one correspondence between symbols, not guaranteeing that the decipher could be made in a unique way.
Your task is, given the parameters and and the alphabet size, decipher a message with symbols or show that it not possible to do so.
Input
The first line of the input consists in an integer number that corresponds to the message size. The second line consists of integer numbers Mi that correspond to the message itself. The third line contains three integers: T that corresponds to the alphabet size; and and as specified before.
Output
The output consists in a single line containing the deciphered message, with its symbols separated by a single blank space, if will be possible to decipher each symbol of the alphabet in a single mode. Otherwise, print the message "DECIFRAGEM AMBIGUA" (ambiguous decipher).
Input Samples | Output Samples |
---|---|
7 2 6 3 0 4 1 5 7 4 2 |
0 1 2 3 4 5 6
|
3 6 79 44 108 73 41 |
1 2 3
|
3 73 60 49 119 25 48 |
1 10 100
|