human
Write me a Python program to find the minimum number of hours required to copy the update files to all n computers if there are only k patch cables in Berland State University given the following:
Berland State University has received a new update for the operating system. Initially it is installed only on the 1-st computer.

Update files should be copied to all n computers. The computers are not connected to the internet, so the only way to transfer update files from one computer to another is to copy them using a patch cable (a cable connecting two computers directly). Only one patch cable can be connected to a computer at a time. Thus, from any computer where the update files are installed, they can be copied to some other computer in exactly one hour.

Your task is to find the minimum number of hours required to copy the update files to all n computers if there are only k patch cables in Berland State University.

Input

The first line contains a single integer t (1 ≤ t ≤ 10^5) — the number of test cases.

Each test case consists of a single line that contains two integers n and k (1 ≤ k ≤ n ≤ 10^{18}) — the number of computers and the number of patch cables.

Output

For each test case print one integer — the minimum number of hours required to copy the update files to all n computers.

Example

Input

4
8 3
6 6
7 1
1 1

Output

4
3
6
0

Note

Let's consider the test cases of the example:

  * n=8, k=3: 
    1. during the first hour, we copy the update files from the computer 1 to the computer 2.

    2. during the second hour, we copy the update files from the computer 1 to the computer 3, and from the computer 2 to the computer 4.

    3. during the third hour, we copy the update files from the computer 1 to the computer 5, from the computer 2 to the computer 6, and from the computer 3 to the computer 7.

    4. during the fourth hour, we copy the update files from the computer 2 to the computer 8. 
  * n=6, k=6: 
    1. during the first hour, we copy the update files from the computer 1 to the computer 2.

    2. during the second hour, we copy the update files from the computer 1 to the computer 3, and from the computer 2 to the computer 4.

    3. during the third hour, we copy the update...
Using python3 can you solve the prior task?
assistant
#Here is Python program to find the minimum number of hours required to copy the update files to all n computers if there are only k patch cables in Berland State University.

import sys

input = sys.stdin.readline
t = int(input())
for _ in range(t):
    n, k = [int(w) for w in input().split()]

    l = 0
    p2 = 1
    while p2 <= k:
        p2 *= 2
        l += 1
    p2 //= 2
    l -= 1
    r = k - p2

    def maxp(n):
        p = 1
        ct = 0
        while p < n:
            p *= 2
            ct += 1
        return ct

    if n <= 2 ** (l + 1):
        print(maxp(n))
        continue
    n -= 2 ** (l + 1)
    print((n - 1) // k + 1 + l + 1)