CF2184C.Huge Pile

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Huge Pile

Andrei has a huge pile of nn apples. He can divide the pile into two smaller piles: if there are xx apples in the pile, he will get piles with x2\lfloor \frac{x}{2} \rfloor^{\text{∗}} and x2\lceil \frac{x}{2} \rceil^{\text{†}} apples. This division takes Andrei 11 minute.

Andrei wants to eat kk apples, but he doesn't want to count them at all. That is why he wants to obtain a pile that contains exactly kk apples. Determine whether it is possible to achieve this by performing pile divisions. If it is possible, find the minimum possible time for Andrei to obtain a pile with exactly kk apples.

^{\text{∗}}x2\lfloor \frac{x}{2} \rfloor — the largest integer x2\le \frac{x}{2}.

^{\text{†}}x2\lceil \frac{x}{2} \rceil — the smallest integer x2\ge \frac{x}{2}.

Input

Each test consists of several test cases. The first line contains a single integer tt (1t104)(1 \le t \le 10^4) — the number of test cases. The following lines describe the test cases.

In the only line of each test case, two integers nn and kk are given — the number of apples in the huge pile and the number of apples that Andrei wants to obtain in one pile (1n,k109)(1 \le n, k \le 10^9).

Output

For each test case, output 1-1 if it is impossible to obtain a pile with exactly kk apples. Otherwise, output the minimum possible time required to obtain such a pile.

Note

In the first test case, after the first division, two piles of 55 apples will be created. If one of them is divided, it will result in piles with 22 and 33 apples, so the answer is 22.

In the second test case, if the pile is divided into two, it will result in piles with 55 and 66 apples, so the answer is 11.

In the third test case, it is only possible to obtain piles with 11, 22, 33, 55, 66, 1010, 1111, or 2121 apples, so the answer is 1-1.

Samples

4
10 3
11 5
21 4
1000000000 1
2
1
-1
29

在线编程 IDE

建议全屏模式获得最佳体验