Problems
Amiria is a cautious internet user, and as such, she is setting up two-factor authentication for her accounts. She is using a special type of security key as an extra precaution to outsmart any intruders that may want to take it. Amiria's security key requires a code to activate. To enter the code, one must place it on wheels with numbers, similar to code padlocks.
Amiria's security key has a sequence of
There is no hidden password. To activate the security key Amiria needs to move the wheels such
that the sequence of numbers shown is palindromic. That is, the sequence of numbers is the
same when read from left to right and from right to left. To slow down intruders, Amiria rigged
the security key such that the wheels only rotate in increments of
Amiria wants to check how much this system would slow down an intruder trying to use her security key. Given the number of wheels and the number currently shown on each wheel, find the minimum number of operations needed to make the sequence of shown numbers palindromic, or report that it is impossible to do so.
Input
The first line of the input gives the number of test cases,
Output
For each test case, output one line containing Case #,
where IMPOSSIBLE instead.
Example
3
5 5 4
1 4 5 5 4
3 4 2
3 4 3
2 4 2
1 4
Case #1: 3
Case #2: 0
Case #3: IMPOSSIBLE