#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
long long int mod = 1e9 + 7;
const long long int INFLL = 0x3f3f3f3f3f3f3f3fll;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1.0);
long long int ksm(long long int a, long long int b) {
  long long int rec = 1;
  while (b) {
    if (b % 2) {
      rec *= a;
      rec %= mod;
    }
    long long int tmp = a % mod;
    a = tmp * tmp;
    a %= mod;
    b >>= 1;
    rec %= mod;
  }
  rec %= mod;
  return rec;
}
unsigned long long int fpow(unsigned long long int a,
                            unsigned long long int b) {
  unsigned long long int rec = 1;
  while (b) {
    if (b % 2) {
      rec *= a;
    }
    unsigned long long int tmp = a;
    a = tmp * tmp;
    b >>= 1;
  }
  return rec;
}
double dpow(double a, long long int b) {
  double rec = 1;
  while (b) {
    if (b % 2) {
      rec *= a;
    }
    double tmp = a;
    a = tmp * tmp;
    b >>= 1;
  }
  return rec;
}
int lowbit(int lowbitn) { return lowbitn & (-lowbitn); }
long long int lowbit(long long int lowbitn) { return lowbitn & (-lowbitn); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int tmp = 1;
    long long int ans = 0;
    while (tmp < k) {
      tmp <<= 1;
      ans++;
    }
    if (n > tmp) {
      ans += (n - tmp) / k;
      if ((n - tmp) % k) {
        ans++;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}

### Prompt

Please create a solution in CPP to the following problem:

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 files from the computer 1 to the computer 5, and from the computer 2 to the computer 6. 
  * n=7, k=1: 
    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; 
    3. during the third hour, we copy the update files from the computer 1 to the computer 4; 
    4. during the fourth hour, we copy the update files from the computer 4 to the computer 5; 
    5. during the fifth hour, we copy the update files from the computer 4 to the computer 6; 
    6. during the sixth hour, we copy the update files from the computer 3 to the computer 7. 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
long long int mod = 1e9 + 7;
const long long int INFLL = 0x3f3f3f3f3f3f3f3fll;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1.0);
long long int ksm(long long int a, long long int b) {
  long long int rec = 1;
  while (b) {
    if (b % 2) {
      rec *= a;
      rec %= mod;
    }
    long long int tmp = a % mod;
    a = tmp * tmp;
    a %= mod;
    b >>= 1;
    rec %= mod;
  }
  rec %= mod;
  return rec;
}
unsigned long long int fpow(unsigned long long int a,
                            unsigned long long int b) {
  unsigned long long int rec = 1;
  while (b) {
    if (b % 2) {
      rec *= a;
    }
    unsigned long long int tmp = a;
    a = tmp * tmp;
    b >>= 1;
  }
  return rec;
}
double dpow(double a, long long int b) {
  double rec = 1;
  while (b) {
    if (b % 2) {
      rec *= a;
    }
    double tmp = a;
    a = tmp * tmp;
    b >>= 1;
  }
  return rec;
}
int lowbit(int lowbitn) { return lowbitn & (-lowbitn); }
long long int lowbit(long long int lowbitn) { return lowbitn & (-lowbitn); }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int tmp = 1;
    long long int ans = 0;
    while (tmp < k) {
      tmp <<= 1;
      ans++;
    }
    if (n > tmp) {
      ans += (n - tmp) / k;
      if ((n - tmp) % k) {
        ans++;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}

```