description: You are given an array consisting of all integers from [l, r] inclusive. For example, if l = 2 and r = 5, the array would be [2, 3, 4, 5]. What's the minimum number of elements you can delete to make the [bitwise AND](https://en.wikipedia.org/wiki/Bitwise_operation#AND) of the array non-zero?
  
  A bitwise AND is a binary operation that takes two equal-length binary representations and performs the AND operation on each pair of the corresponding bits.
  
  Input
  
  The first line contains one integer t (1 ≤ t ≤ 10^4) — the number of test cases. Then t cases follow.
  
  The first line of each test case contains two integers l and r (1 ≤ l ≤ r ≤ 2 ⋅ 10^5) — the description of the array.
  
  Output
  
  For each test case, output a single integer — the answer to the problem.
  
  Example
  
  Input
  
  
  5
  1 2
  2 8
  4 5
  1 5
  100000 200000
  
  
  Output
  
  
  1
  3
  0
  2
  31072
  
  Note
  
  In the first test case, the array is [1, 2]. Currently, the bitwise AND is 0, as 1\ \& \ 2 = 0. However, after deleting 1 (or 2), the array becomes [2] (or [1]), and the bitwise AND becomes 2 (or 1). This can be proven to be the optimal, so the answer is 1.
  
  In the second test case, the array is [2, 3, 4, 5, 6, 7, 8]. Currently, the bitwise AND is 0. However, after deleting 4, 5, and 8, the array becomes [2, 3, 6, 7], and the bitwise AND becomes 2. This can be proven to be the optimal, so the answer is 3. Note that there may be other ways to delete 3 elements.
solution: 
  import java.io.*;
  
  import java.util.*;
  
  
  public class Main {
  
      public static void main(String[] args) throws IOException {
          Reader.init(System.in);
          BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
          int[][] q = new int[200001][18];
  
          int i = 1;
          while ( i <= 200000){
              int v = i;
              int j = 0;
              while ( j <= 17){
                  q[i][j] = q[i-1][j];
                  j++;
              }
              j = 0;
              while ( v != 0){
                  if ( (v&1) == 1){
                     q[i][j]+=1;
  
                  }
                  j++;
                  v = v>>1;
              }
              i++;
          }
          int t = Reader.nextInt();
          while ( t > 0 ){
              int l = Reader.nextInt();
              int r = Reader.nextInt();
              int [] array = new int[18];
              i = 0;
              int max = -1;
              while (i<18){
                  array[i] = q[r][i]-q[l-1][i];
                  if ( array[i] > max){
                      max = array[i];
                  }
                  i++;
  
              }
              int total = r-l+1;
              total-=max;
              output.write(total+"\n");
  
  
  
              t--;
          }
  
  
  
          output.flush();
  
  
      }
      public static int sub(int a, int b){
          int half = b/2;
          if ( b%2 == 0){
              if ( a < half){
                  return 1;
              }
              else{
                  return -1;
              }
          }
          else{
              if ( a<= half){
                  return 1;
              }
              else{
                  return -1;
              }
          }
      }
  
  
      private static int bs(int low,int high,ArrayList<Integer> array,int find){
          if ( low <= high ){
              int  mid = low + (high-low)/2;
              if ( array.get(mid) > find){
                  high = mid -1;
                  return bs(low,high,array,find);
              }
              else if ( array.get(mid) < find){
                  low = mid+1;
                  return bs(low,high,array,find);
              }
              return mid;
          }
          return -1;
      }
  
      private static long max(long a, long b) {
          return  Math.max(a,b);
      }
  
      private static long min(long a,long b){
          return  Math.min(a,b);
      }
  
      public static long modularExponentiation(long a,long b,long mod){
          if ( b == 1){
              return a;
          }
          else{
              long ans = modularExponentiation(a,b/2,mod)%mod;
              if ( b%2 == 1){
                  return (a*((ans*ans)%mod))%mod;
              }
  
              return ((ans*ans)%mod);
          }
      }
  
      public static long sum(long n){
          return  (n*(n+1))/2;
      }
      public static long abs(long a){
          return a < 0 ? (-1*a) : a;
      }
      public static long gcd(long a,long b){
          if ( a == 0){
              return b;
          }
          else{
              return gcd(b%a,a);
          }
      }
  
  
  }
  
  class Reader {
      static BufferedReader reader;
      static StringTokenizer tokenizer;
  
  
      static void init(InputStream input) {
          reader = new BufferedReader(
                  new InputStreamReader(input));
          tokenizer = new StringTokenizer("");
      }
  
      static String next() throws IOException {
          while ( ! tokenizer.hasMoreTokens() ) {
  
              tokenizer = new StringTokenizer(
                      reader.readLine() );
          }
          return tokenizer.nextToken();
      }
  
      static int nextInt() throws IOException {
          return Integer.parseInt( next() );
      }
  
      static double nextDouble() throws IOException {
          return Double.parseDouble( next() );
      }
  
      static long nextLong() throws IOException{
          return Long.parseLong(next());
      }
  }
  /*
  class NComparator implements Comparator<Node>{
      @Override
      public int compare(Node o1, Node o2) {
          if ( o2.position > o1.position){
              return 1;
          }
          else if ( o2.position < o1.position){
              return -1;
          }
          else{
              if ( o2.time < o1.time){
                  return 1;
              }
              else if ( o2.time > o2.time){
                  return -1;
              }
              else{
                  return 0;
              }
          }
      }
  }
  
  
  class DComparator implements Comparator<Integer>{
      @Override
      public int compare(Integer o1, Integer o2) {
          if ( o2 > o1){
              return 1;
          }
          else if ( o2 < o1){
              return -1;
          }
          else{
              return 0;
          }
      }
  }
  
  */
  class Queries{
      int type;
      int val1;
      int val2;
  
      Queries(int a,int b,int c){
          type = a;
          val1 = b;
          val2 = c;
      }
  
  }