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: import java.math.BigInteger;
  import java.util.*;
  import java.io.*;
  
  public class B_Update_Files {
      public static void main (String[] args) {
          FastReader scan = new FastReader();
          int t = scan.nextInt();
          while (t-- > 0) {
              long n = scan.nextLong(), k = scan.nextLong();
              if (k == 1) {
                  System.out.println(n - 1);
                  continue;
              }
              if (n == 1) {
                  System.out.println(0);
                  continue;
              }
              long ans = 0, done = 1;
              while (done < n) {
                  if (done <= k) {
                      done *= 2;
                      ans++;
                  }
                  else {
                      ans += (n - done) / k;
                      if ((n - done) % k != 0) {
                          ans++;
                      }
                      break;
                  }
              }
              System.out.println(ans);
          }
      }
      static long nextPowerOf2(long n)
      {
          long count = 0;
          if (n > 0 && (n & (n - 1)) == 0)
              return n;
   
          while(n != 0)
          {
              n >>= 1;
              count += 1;
          }
   
          return 1 << count;
      }
      public static void inputArray (int[] arr, int n, FastReader scan) {
          for (int i=0; i<n; i++) {
              arr[i] = scan.nextInt();
          }
      }
      public static void printArray (int[] arr) {
          for (int i=0; i<arr.length; i++) {
              System.out.print(arr[i] + " ");
          }
          System.out.println();
      }
      public static boolean isPrime (int n) {
          if (n <= 1)
              return false;
          if (n <= 3)
              return true;
          if (n % 2 == 0 || n % 3 == 0)
              return false;
          for (int i = 5; i * i <= n; i = i + 6)
              if (n % i == 0 || n % (i + 2) == 0)
                  return false;
          return true;
      }
      public static int gcd (int a, int b) {
          BigInteger a1 = BigInteger.valueOf(a);
          BigInteger b1 = BigInteger.valueOf(b);
          return a1.gcd(b1).intValue();
      }
      public static int numberOfDigitsInNumber (int n) {
          return (int)Math.floor(Math.log10(n)) + 1;
      }
      public static boolean isPowerOfTwo (int x) {
          return x!=0 && ((x&(x-1)) == 0);   
      }
      public static String toBinaryString (int n) {
          return Integer.toString(n, 2);
          // for other bases change 2 to other bases
      }
      static class FastReader {
          BufferedReader br;
          StringTokenizer st;
   
          public FastReader()
          {
              br = new BufferedReader(
                  new InputStreamReader(System.in));
          }
   
          String next()
          {
              while (st == null || !st.hasMoreElements()) {
                  try {
                      st = new StringTokenizer(br.readLine());
                  }
                  catch (IOException e) {
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
   
          int nextInt() { return Integer.parseInt(next()); }
   
          long nextLong() { return Long.parseLong(next()); }
   
          double nextDouble()
          {
              return Double.parseDouble(next());
          }
   
          String nextLine()
          {
              String str = "";
              try {
                  str = br.readLine();
              }
              catch (IOException e) {
                  e.printStackTrace();
              }
              return str;
          }
      }
  }
  
  // For IO using Files
  // public static void main throws IOException
  // BufferedReader br = new BufferedReader(new FileReader("input.txt"));
  // PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
  // String st[]=br.readLine().split(" ");
  // int n=Integer.parseInt(st[0]);
  // int m=Integer.parseInt(st[1]);
  // at the end
  // br.close(); pw.close();
  // for printing pw.println(), pw.print(), etc...
  // for arrays : int arr[] = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();