Problems
As the most skilled alchemist in your country, you were summoned yet again because powers beyond science were needed to satisfy your country's leader's ever increasing greed for rare metals.
Each metal is represented by a positive integer. You need to create
Unfortunately, budget cuts have left you only the materials for a simple alchemy spell.
For some fixed numbers
You have been assigned an expert miner to assist you. The expert miner can fetch a single unit of
any metal you want. From that unit, you can use your spell to create other metals
and then use the spell on the resulting metals to create even more units. The picture below shows a
single unit of metal
Metals represented by larger integers are heavier and more difficult to handle, so you want to ask the expert miner for a single unit of metal represented by the smallest possible integer that is sufficient to complete your task, or say that there is no such metal.
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
if it is not possible to create all required units starting from a single unit of metal.
Otherwise,
Example #1
3
2 1 2
1 2
5 1 2
2 0 0 0 1
3 1 2
1 1 1
Case #1: 4
Case #2: 6
Case #3: 5
Example #2
3
3 2 4
1 1 1
3 2 4
1 0 1
5 2 5
1 0 0 0 1
Case #1: IMPOSSIBLE
Case #2: 5
Case #3: 10