Interesting Set
题号:NC15337
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Mr.Frog is researching integers.

He converts two integers X and Y into binary system without leading zeros, if they have the same quantity of 0 and the same quantity of 1 in the binary system, Mr.Frog will think these two integers are friendly.               

For example, 5(10) = 101(2) and 6(10) = 110(2), both of them have two 1 and one 0 in the binary system, so Mr.Frog thinks 5 and 6 are friendly.              

Now, Mr.frog gets an integer N and defines a sorted set S. The sorted set S consists of integers which are friendly with N and bigger than N. He wants to know what is the Kth integer in S.                

Because Mr.Frog is on his way back from Hong Kong to Beijing, he wants to ask you for help.

输入描述:

The first line contains an integer T, where T is the number of test cases. T test cases follow. 
For each test case, the only line contains two integers N and K.
         
• 1 ≤ T ≤ 200. 
• 1 ≤ N ≤ 1018
• 1 ≤ K ≤ 1018

输出描述:

For each test case, print one line containing “Case #x: y”, where x is the test case number (startingfrom 1) and y is the Kth integer in the sorted set S. If the integer he wants to know does not exist, y is“ IMPOSSIBLE”.

示例1

输入

复制
2
9 2
7 4

输出

复制
Case #1: 12
Case #2: IMPOSSIBLE

备注:

For the first case, the sorted set S is {10, 12}, so the 2nd integer is 12. 
For the second case, the sorted set S is ∅, so the answer is “IMPOSSIBLE”.