CF2182B.New Year Cake

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

New Year Cake

Monocarp is going to bake a New Year cake.

The cake must consist of at least one layer. The size of the top layer of the cake must be 11; the size of the layer below it must be 22; the layer below that must be 44, and so on (each layer, except for the top one, is twice the size of the layer above it).

Additionally, each layer must be covered with either white or dark chocolate. To cover a layer of size kk, Monocarp will need kk kilograms of chocolate. Each layer must be covered with exactly one type of chocolate, and these types must alternate (if some layer is covered with dark chocolate, both the layer directly below it and the layer directly above it must be covered with white chocolate, and vice versa).

Monocarp has aa kilograms of white chocolate and bb kilograms of dark chocolate. He wants to calculate the maximum number of layers that the cake can consist of, ensuring that he has enough chocolate of both types.

Input

The first line contains one integer tt (1t1041 \le t \le 10^4) — the number of test cases.

Each test case consists of one line containing two integers aa and bb (1a,b1061 \le a, b \le 10^6).

Output

For each test case, output one integer — the maximum possible number of layers in the cake.

Note

In the first example, Monocarp can bake a cake with one layer of size 11 and cover it with any type of chocolate.

In the second example, Monocarp can bake a cake with two layers: the top layer of size 11 with white chocolate, and below it a layer of size 22 with dark chocolate.

In the third example, Monocarp can bake a cake with two layers: the top layer of size 11 with dark chocolate, and below it a layer of size 22 with white chocolate.

In the fourth example, Monocarp can bake a cake with two layers: the top layer of size 11 with dark chocolate, and below it a layer of size 22 with white chocolate. Note that a cake with three layers, where the top layer of size 11 and the layer below it of size 22 are both dark chocolate, and the bottom layer of size 44 is white chocolate, is not valid, as the types of layers must alternate.

Samples

7
1 1
1 2
3 1
4 3
5 2
1000000 1000000
1000000 1
1
2
2
2
3
20
2

在线编程 IDE

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