#K56192. Magician's Deck Sorting

    ID: 30144 Type: Default 1000ms 256MiB

Magician's Deck Sorting

Magician's Deck Sorting

You are given a deck consisting of N cards numbered from 1 to N. In one operation, a specific card move is performed to try to arrange the deck so that the card at the i-th position (from the top) is exactly the card numbered i for every 1 ≤ iN. Your task is to determine the minimum number of operations required to achieve the target configuration.

The operations follow the rules below:

  • If N = 1, the deck is already sorted.
  • If N is even, it is proven that sorting the deck using the allowed operations is impossible. In this case, output IMPOSSIBLE.
  • If N is odd and greater than 1, it takes exactly N operations to sort the deck.

This result can be represented mathematically as follows:

[ \text{min_operations}(N) = \begin{cases} 0, & \text{if } N = 1,\ \text{IMPOSSIBLE}, & \text{if } N \text{ is even},\ N, & \text{if } N > 1 \text{ and odd}. \end{cases} ]

You need to process multiple test cases.

inputFormat

The first line of input contains a single integer T representing the number of test cases. Each of the following T lines contains a single integer N representing the number of cards in the deck for that test case.

Input is provided through stdin.

outputFormat

For each test case, output on a separate line the minimum number of operations required to sort the deck according to the rules described above. If it is impossible, print IMPOSSIBLE.

Output should be sent to stdout.

## sample
3
1
2
3
0

IMPOSSIBLE 3

</p>