Ayan is a small kid loves to play with stars *
and dots .
and builds different triangles. Today he builds a triangular shape as follows and named it TriangleLevel0.
|
Figure 0 TriangleLevel0 |
By placing two TriangleLevel0(s) side by side and one TriangleLevel0 below them, he builds a new structure (in figure 1.1). Then gaps are filled with dots .
. Then he names the structure as TriangleLevel1 (in figure 1.2). And similarly, we can also construct Trianglelevel2.
|
|
|
Figure 1.1 New Structure (Without dots) |
Figure 1.2 TriangleLevel1 |
Figure 2 TriangleLevel2 |
He repeated the same procedure until he built the TriangleLevelN. Now he wants to know how many stars are in the Kth row after building TriangleLevelN.
For example, if N = 2, then after building TriangleLevel2, 1st row (counting of rows starts from the bottom) has 1 star, 2nd and 3rd row has 2 stars each, 4th row has 4 stars, 5th row has 2 stars, and so on.
Input
Input starts with an integer T (1 ≤ T ≤ 100000) denoting the number of test cases. Each of the test cases will contain two numbers K (1 ≤ K ≤ 1016) and N (0 ≤ N ≤ 50).
Output
The output should be in the format Case t: x
where t is the case number and x is the number of stars. If there is no such row in the triangle of level N, then print -1 instead.
Sample
Sample Input | Sample Output |
---|---|
4 1 1 2 3 5 3 20 2 | Case 1: 1 Case 2: 2 Case 3: 2 Case 4: -1 |