传统题 1000ms 256MiB

Game Theory

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

Libra and Rahn are playing a game.

Libra has a non-negative integer AA and Rahn has a non-negative integer BB. Libra wants to take several steps to change AA to BB. Each step Libra can take one of the following operations:

  • Add 11 to AA (AA+1A\to A+1).
  • Multiply AA by 22 (A2AA \to 2A).
  • Divide AA by 22 (AA2A \to \frac{A}{2}). Note that Libra can take this operation only if AA is even.

Libra wants to know the minimum steps to change AA to BB using the operations above.

Format

Input

The first line contains one integer T(1T10000)T(1\le T\le 10000) -- the number of test cases.

For each test case there is a single line contains two integers A,B(1A,B1018)A,B(1\le A,B\le 10^{18}).

Output

For each test case, output a line with an integer representing the minimum steps Libra needs to take.

Samples

6
31 13
12 8
25 6
10 24
1 1
997 120
8
3
8
3
0
20

五一欢乐训练赛

未参加
状态
已结束
规则
ACM/ICPC
题目
6
开始于
2023-5-2 14:00
结束于
2023-5-2 18:00
持续时间
4 小时
主持人
参赛人数
6