description: 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. 
solution: #include <bits/stdc++.h>
  using namespace std;
  #pragma GCC optimize("Ofast,no-stack-protector")
  #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  #pragma GCC optimize("unroll-loops")
  inline bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
    if (a.second == b.second) return a.first < b.first;
    return a.second > b.second;
  }
  int drx[8] = {-2, -2, -1, -1, 1, 1, 2, 2};
  int dcy[8] = {-1, 1, -2, 2, -2, 2, -1, 1};
  int dirx[4] = {-1, 0, 1, 0};
  int diry[4] = {0, -1, 0, 1};
  long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
      if (b & 1) res = res * a % m;
      a = a * a % m;
      b >>= 1;
    }
    return res;
  }
  long long InverseMod(long long base, long long pow) {
    if (pow == 0) return 1;
    long long ans = InverseMod(base, pow / 2);
    ans = (ans * ans) % 1000000007;
    if (pow & 1) {
      return (ans * base) % 1000000007;
    } else {
      return ans;
    }
  }
  bool isprime(long long num) {
    if (num < 2) return false;
    for (long long i = 2; i * i <= num; i++) {
      if (num % i == 0) return false;
    }
    return true;
  }
  long long EularPHI(long long num) {
    double ans = num;
    for (long long i = 2; i * i <= num; i++) {
      if (num % i == 0) {
        while (num % i == 0) {
          num /= i;
        }
        ans *= (1.0 - (1.0 / (double)i));
      }
    }
    if (num > 1) ans *= (1.0 - (1.0 / (double)num));
    return (long long)ans;
  }
  template <class T>
  inline T gcd(T a, T b) {
    if (b == 0) return a;
    return gcd(b, a % b);
  }
  template <class T>
  inline T lcm(T a, T b) {
    return a * b / gcd<T>(a, b);
  }
  template <class T>
  inline T power(T b, T p) {
    long long ans = 1;
    while (p--) ans *= b;
    return ans;
  }
  int binomialCoeff(int n, int r) {
    if (r > n) return 0;
    int m = 1000000007;
    int inv[r + 1];
    memset(inv, 0, sizeof(inv));
    inv[0] = 1;
    if (r + 1 >= 2) inv[1] = 1;
    for (int i = 2; i <= r; i++) {
      inv[i] = m - (m / i) * inv[m % i] % m;
    }
    int ans = 1;
    for (int i = 2; i <= r; i++) {
      ans = ((ans % m) * (inv[i] % m)) % m;
    }
    for (int i = n; i >= (n - r + 1); i--) {
      ans = ((ans % m) * (i % m)) % m;
    }
    return ans;
  }
  long long extgcd(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
      x = 1;
      y = 0;
      return a;
    }
    long long x1, y1;
    long long d = extgcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
  }
  bool find_any_solution(long long a, long long b, long long c, long long &x0,
                         long long &y0, long long &g) {
    g = extgcd(abs(a), abs(b), x0, y0);
    if (c % g) {
      return false;
    }
    x0 *= c / g;
    y0 *= c / g;
    if (a < 0) x0 = -x0;
    if (b < 0) y0 = -y0;
    return true;
  }
  long long powm(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
      if (b & 1) res = res * a;
      a = a * a;
      b >>= 1;
    }
    return res;
  }
  long long divide(long long a, long long b) {
    return (a % 1000000007) * powm(b, 1000000007 - 2) % 1000000007;
  }
  long long mul(long long a, long long b) {
    return ((a % 1000000007) * (b % 1000000007)) % 1000000007;
  }
  long long add(long long a, long long b) {
    return (a % 1000000007 + b % 1000000007) % 1000000007;
  }
  bool vectorSortedOrNot(vector<int> v, int n) {
    if (n == 1 || n == 0) return 1;
    if (v[n - 1] < v[n - 2]) return 0;
    return vectorSortedOrNot(v, n - 1);
  }
  int sumDigits(int num) { return num == 0 ? 0 : num % 10 + sumDigits(num / 10); }
  void Divisors(long long n) {
    for (long long i = 1; i <= sqrt(n); i++) {
      if (n % i == 0) {
      }
    }
  }
  long long solve(long long mid, long long k) {
    long long sum = 0;
    long long z = 1;
    while (mid / z > 0) {
      sum += mid / z;
      z *= k;
    }
    return sum;
  }
  int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << fixed << setprecision(0);
    long long test = 1;
    cin >> test;
    while (test--) {
      long long n, k;
      cin >> n >> k;
      if (n - 1) {
        long long ans(0);
        long long updatedon(1);
        while (updatedon <= k and updatedon < n) {
          updatedon *= 2;
          ans++;
        }
        n -= updatedon;
        if (n > 0) {
          ans += n / k;
          if (n % k) ans++;
        }
        cout << ans;
        cout << '\n';
      } else {
        cout << 0 << "\n";
      }
    }
    return 0;
  }
  