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.io.*;
  import java.util.*;
  public class Codeforces2 {
      public static void main(String[] args)throws IOException {
          FastReader sc = new FastReader();
          BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
          //t -> test cases;
          long t = sc.nextLong();
          while(t-->0){
              long n = sc.nextLong();
              long k = sc.nextLong();
              long time=0;
              long done=1;
              n--;
              while(n>0){
                  if(done<=k){
                      n-=done;
                      time++;
                      done*=2;
                  }else{
                      //done+=k;
                      if(n%k==0){
                          time+=n/k;
                          break;
                      }else{
                          time+=(n/k+1);
                          break;
                      }
                  }
              }
              output.write(time+"\n");
              
          }
          output.flush();
      }
  
      //Max Sliding Window
      static ArrayList<Integer> findKMaxElement(int[] arr, int k, int n)
      {
          // creating the max heap ,to get max element always
          PriorityQueue<Integer> queue = new PriorityQueue<>(
              Collections.reverseOrder());
   
          ArrayList<Integer> res = new ArrayList<>();
          int i = 0;
   
          for (; i < k; i++)
              queue.add(arr[i]);
   
          // adding the maximum element among first k elements
          res.add(queue.peek());
   
          // removing the first element of the array
          queue.remove(arr[0]);
   
          // iterarting for the next elements
          for (; i < n; i++) {
   
              // adding the new element in the window
              queue.add(arr[i]);
   
              // finding & adding the max element in the
              // current sliding window
              res.add(queue.peek());
   
              // finally removing the first element from front
              // end of queue
              queue.remove(arr[i - k + 1]);
          }
          return res;
          // this code is Contributed by Pradeep Mondal P
      }
  
  
      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;
          }
      }
      //Number of bits
      static int numberOfBits(int n){
          return (int)(Math.log(n)/Math.log(2)+1);
      }
      
      //GCD of a Two number
      static long GCD(long a, long b){
          if(b==0)
          return a;
          return GCD(b, a%b);
      }
  
      //No of factors in factorial n i.e. (n!)
      static long factors(long n, long b){
          long count =0;
          int power = 1;
          while(n>=b){
              count+=n/b;
              b=(long)Math.pow(b, ++power);
          }
          return count;
      }
      
      //prime numbers in a range from 2 to n
      static boolean[] primeUptoN(int n){
          boolean arr[]= new boolean[n];
          return arr;
      }
  
      //Round off
      static double roundOff(double value, int digit){
          double mul = Math.pow(10.0, digit);
          value=Math.round((value*mul)/mul);
          return value;
      }
  }
  /*class Pair{
      long data1;
      long data2;
      public Pair(long data1, long data2){
          this.data1=data1;
          this.data2=data2;
      }
  }
  
  class SortByData1 implements Comparator<Pair>{
      public int compare(Pair a, Pair b){
          int result = 0;
          if(a.data1>b.data1){
              result=1;
          }else if(b.data1>a.data1){
              result=-1;
          }
          return result;
      }
  }*/