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.util.*;
  import java.util.regex.Pattern;
  
  import javax.lang.model.element.Element;
  import javax.sql.rowset.spi.SyncResolver;
  import javax.swing.text.TableView;
  import javax.swing.text.StyledEditorKit.BoldAction;
  
  import java.io.*;
  import java.nio.file.attribute.GroupPrincipal;
  import java.nio.file.attribute.PosixFilePermission;
  import java.sql.PseudoColumnUsage;
  
  public class Solution {
  
      static FastReader fr = new FastReader();
      static final Random random = new Random();
      static long mod = 1000000007L;
       static boolean kbitnotSet(int n,
                                     int k)
      {
          if ((n & (1 << (k - 1))) > 0)
              return false;
          else
              return true;
              
  
      }
      static int msb(int n)
      {
          int count=0;
          while(n>0)
          {
              n/=2;
              count++;
          }
          return count;
      }
          public static void main(String args[]) throws IOException {
          
          // int t= fr.nextInt();
          int[][] precom = new int[200001][20];
          for(int i=1;i<=200000;i++)
          {
              for(int j=1;j<20;j++)
              {
                  if(kbitnotSet(i, j))
                  precom[i][j] = precom[i-1][j]+1;
                  else
                  precom[i][j] = precom[i-1][j];
              }
          }
         
           StringBuilder str = new StringBuilder();
          int t= fr.nextInt();
          
              // System.out.println( emotesUpto(5, t));
          while(t-->0)
          {
              int l= fr.nextInt();
              int r= fr.nextInt();
             
              int msbl = msb(l);
              int msbr = msb(r);
              // System.out.println("msb"+msb+" "+l);
              int min = Integer.MAX_VALUE;
              for(int j=msbl ;j<=msbr;j++)
              {
                    
                  int zeroes = precom[r][j]-precom[l][j];
                  if(kbitnotSet(l, j))
                  zeroes++;
                  min = Math.min(min,zeroes);
              }
             
              str.append(min+"\n");
              //    StringBuilder s = new StringBuilder();
             
              
          }
          System.out.println(str.toString());
  
      }
  
      static void printArray(int[] a) {
          System.out.println();
          for (int i = 0; i < a.length; i++) {
  
              System.out.println(a[i] );
              // System.out.println();
          }
          System.out.println();
      }
  
      static int max(int a, int b) {
          if (a < b)
              return b;
          return a;
      }
  
      static void ruffleSort(int[] a) {
          int n = a.length;
          for (int i = 0; i < n; i++) {
              int oi = random.nextInt(n), temp = a[oi];
              a[oi] = a[i];
              a[i] = temp;
          }
          Arrays.sort(a);
      }
  
      static <E> void print(E res) {
          System.out.println(res);
      }
  
      static int gcd(int a, int b) {
          if (b == 0) {
              return a;
          }
          return gcd(b, a % b);
      }
  
      static int lcm(int a, int b) {
          return (a / gcd(a, b)) * b;
      }
  
      static int abs(int a) {
          if (a < 0)
              return -1 * a;
          return a;
      }
  
      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;
          }
  
          int[] readintarray(int n) {
              int res[] = new int[n];
              for (int i = 0; i < n; i++)
                  res[i] = nextInt();
              return res;
          }
  
          long[] readlongarray(int n) {
              long res[] = new long[n];
              for (int i = 0; i < n; i++)
                  res[i] = nextLong();
              return res;
          }
      }
  
  }
  