Problems
You are given a starting non-negative integer
- Double your current value.
-
Take the bitwise NOT of your current value. The binary representation of your current value
is taken without unnecessary leading zeroes, and any unnecessary leading zeroes produced by
the operation are dropped. (The only necessary leading zero is the one in the
representation of
0 ).
For example, by using the double operation,
You can use these operations as many times as you want in any order. For example, you can
transform
Determine the smallest number of operations needed to complete the transformation, or say 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
if there is no way to transform
Example
6
10001 111
1011 111
1010 1011
0 1
0 101
1101011 1101011
Case #1: 4
Case #2: 3
Case #3: 2
Case #4: 1
Case #5: IMPOSSIBLE
Case #6: 0