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.io.*;
import java.util.*;

public class Main {
  static FastReader in=new FastReader();
  static PrintStream out=System.out;
  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();
    }
  }
  static int[] na(int n)
  {
    int[] a=new int[n];
    for(int i=0;i<n;i++)a[i]=ni();
    return a;
  }
  static int ni()
  {
    return Integer.parseInt(in.next());
  }
  static long nl()
  {
    return Long.parseLong(in.next());
  }
  static String ns()
  {
    return in.next();
  }

  static void comp(int pos,long num,int digit)
  {
    if(pos<0)return;
    if(digit==0)
    {
      if(num>0 && num<=(1e18))list.add(num);
      return;
    }
    for(int i=1;i<=9;i++)
    {
      comp(pos-1,num*10+i,digit-1);
    }
    comp(pos,num*10,digit-1);
  }
  static ArrayList<Long> list;
  public static void main(String[] args) throws IOException{
    int t=ni();
    list=new ArrayList<>();
    comp(3,0,19);
    Collections.sort(list);
    //out.println(list.size());
    while(t-->0)
    {
      long l=nl(),r=nl();
      int ind1=Collections.binarySearch(list,r);
      if(ind1<0)ind1=-ind1-2;
      int ind2=Collections.binarySearch(list,l);
      if(ind2<0)ind2=-ind2-1;
      out.println((ind1-ind2+1));
    }
  }
}