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.lang.*;
  import java.util.*;
  
  import static java.lang.Math.max;
  
  public class C {
      static int[][] Dp=new int[200001][20];
      private static void solve() throws IOException {
          //Solve here
          int l = sc.nextInt();
          int r = sc.nextInt();
  
          int[] check=new int[20];
          int maxElement = 0;
  
          for (int i=0;i<20;i++){
              maxElement = max(maxElement, Dp[r][i] - Dp[l - 1][i]);
          }
          ans.append((r - l + 1 - maxElement)).append("\n");
      }
  
      public static void main(String[] args) throws IOException {
          int t = sc.nextInt();
          for(int i=1;i<200001;i++){
              int  check = i, idx = 0;
              while (check>0){
                  Dp[i][idx++] += (check % 2);
                  check /= 2;
              }
              for(int j=0;j<20;j++){
                  Dp[i][j] += Dp[i - 1][j];
              }
          }
          while (t-- > 0) {
              solve();
          }
          System.out.println(ans);
      }
  
      static final FastReader sc = new FastReader();
      static StringBuilder ans = new StringBuilder();
      static boolean[] prime;
      static int M = 1_000_000_007;
  
  
      static long gcd(long a, long b){
          if (b == 0)
              return a;
          return gcd(b, a % b);
      }
  
      static long nCk(int n, int k) {
          return (modMult(fact(n), power(modMult(fact(n - k), fact(k)), M - 2)));
      }
  
      static long fact(long n) {
  
          long fact = 1;
          for (int i = 1; i <= n; i++) {
              fact = modMult(fact, i);
          }
          return fact % M;
      }
  
      static long modMult(long a, long b) {
          return a * b % M;
      }
  
      static long power(long x, long y) {
          long res = 1;
          x = x % M;
          if (x == 0)
              return 0;
          while (y > 0) {
              if ((y & 1) != 0)
                  res = (res * x) % M;
              y = y >> 1;
              x = (x * x) % M;
          }
          return res;
      }
  
      static void sieveOfEratosthenes(int n) {
          prime = new boolean[n + 1];
          for (int i = 0; i <= n; i++)
              prime[i] = true;
          prime[0] = false;
          if (1 <= n)
              prime[1] = false;
          for (int p = 2; p * p <= n; p++) {
  
              if (prime[p]) {
  
                  for (int i = p * p; i <= n; i += p)
                      prime[i] = false;
              }
          }
      }
  
      static int[] arrayIn(int n) throws IOException {
          int[] arr = new int[n];
          for (int i = 0; i < n; i++) {
              arr[i] = sc.nextInt();
          }
          return arr;
      }
  
      static class Pair<E, F> {
          private E v1;
          private F v2;
  
          Pair(E v1, F v2) {
              this.v1 = v1;
              this.v2 = v2;
          }
  
          Pair() {
          }
      }
  
      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;
          }
      }
  }
  