Problem: Let's call some positive integer classy if its decimal representation contains no more than 3 non-zero digits. For example, numbers 4, 200000, 10203 are classy and numbers 4231, 102306, 7277420000 are not.

You are given a segment [L; R]. Count the number of classy integers x such that L ≤ x ≤ R.

Each testcase contains several segments, for each of them you are required to solve the problem separately.

Input

The first line contains a single integer T (1 ≤ T ≤ 10^4) — the number of segments in a testcase.

Each of the next T lines contains two integers L_i and R_i (1 ≤ L_i ≤ R_i ≤ 10^{18}).

Output

Print T lines — the i-th line should contain the number of classy integers on a segment [L_i; R_i].

Example

Input

4
1 1000
1024 1024
65536 65536
999999 1000001


Output

1000
1
0
2

Solution (in JAVA):

Solution:
import java.util.*;
import java.io.*;

// Solution

public class Main 
{    
  public static void main (String[] argv) 
  {
	  new Main();
  } 
     
     
  
  boolean test = false;  
  
  
  int W = 19;
      int J = 3;
      long[][] dp;
      
  public Main()  {
	  FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
	  //FastReader in = new FastReader(new BufferedReader(new FileReader("Main.in")));
      int q = in.nextInt();      
      dp = new long[W+1][J+1];
      for (int i = 0; i <= W; i++) dp[i][0] = 1;
      dp[0][1] = 1;
      dp[0][2] = 1;
      dp[0][3] = 1;
      
      for (int i = 1; i <= W; i++) {
          for (int j = 1; j <= J; j++) {
              dp[i][j] = dp[i-1][j] + dp[i-1][j-1] * 9;
              //System.out.println("dp[" + i + "][" + j+ "] = " + dp[i][j]);
          }          
      }
      for (int aa = 0; aa < q; ++aa) {
          long L = in.nextLong();
          long R = in.nextLong();
          long cnt = f(R, 3) - f(L-1, 3);
          System.out.println(cnt);
                
          
      }     
      
  }
  
  // #number <= x and have <= k non-zero digits
  private long f(long x, int k) {
      long cnt = 0;
      
      
      long xx = x;
      long rem = 0;
      int w = 0;
      long mul = 1;
      while (xx >= 10) {          
          rem += (xx % 10) * mul;
          xx /= 10;
          ++w;
          mul *= 10;
      }
      cnt = dp[w][k];
      if (k > 0)
         cnt += (xx-1) * dp[w][k-1] + f(rem, k - 1);
      
      
      //System.out.println("try " + x + "  " + k + " = " + cnt);
      return cnt;
  }
  
  
 
  
  private int nBit1(int v) {
      int v0 = v;
      int c = 0;
      while (v != 0) {
          ++c;
          v = v & (v - 1);
      }
      return c;
  }
  
  private int common(int v) {
      int c = 0;
      while (v != 1) {
          v = (v >>> 1);
          ++c;
      }
      
      return c;
  }
  
  private void reverse(char[] a, int i, int j) {
      while (i < j) {
          swap(a, i++, j--);
      }
  }
  
  private void swap(char[] a, int i, int j) {
      char t = a[i];
      a[i] = a[j];
      a[j] = t;
  }
  
  
  private long gcd(long x, long y) {
      if (y == 0) return x;
      return gcd(y, x % y);
  }
  private int max(int a, int b) {
      return a >  b ? a : b;
  }
  
  private int min(int a, int b) {
      return a >  b ? b : a;
  }
  
  
  static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader(BufferedReader in)
        {            
            br = in;
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    String line = br.readLine();
                    if (line == null || line.length() == 0) return "";
                    st = new StringTokenizer(line);
                }
                catch (IOException  e)
                {
                    return "";
                    //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)
            {
                return "";
                //e.printStackTrace();
            }
            return str;
        }
    }
}