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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class ClassyNumbers {
	static Scanner sc;
	static PrintWriter out;
	static TreeSet<Long> classynum;
	static long[] classy;
	public static void main(String[] args) throws Exception{
		sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		classynum = new TreeSet<Long>();
		classynum.add(1000000000000000000l);
		dp(0, 0, "");
		classy = new long[607420];
		int j = 0;
		for(long l:classynum) {
			classy[j++] = l;
		}	
		int tc = sc.nextInt();
		long start,end;
		while(tc-->0) {
			start = sc.nextLong();
			end = sc.nextLong();
			int index = getIndex(classynum.ceiling(start));
			end = classynum.floor(end);
			int ans = getIndex(end)-index;
			if(ans<0)
				out.println(0);
			else
				out.println(ans+1);
		}
		out.close();
	}
	static int getIndex(long value) {
		int index = Arrays.binarySearch(classy, value);
		if(index<0) {
			index++;
			index*=-1;
		}
		return index;
	}
	static void dp(int i,int cnt,String num) {
		if(cnt == 3)
			return;
		if(i == 18)
			return;
		dp(i+1,cnt,0+num);
		for(int j=1;j<10;j++) {
			classynum.add(Long.parseLong(j+num));
			dp(i+1,cnt+1,j+num);
		}
	}
	static class Scanner{
		private BufferedReader br;
		private StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		private String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException{
			return Double.parseDouble(next());
		}
		public int[] inArr(int n) throws Exception{
			int a [] = new int[n];
			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(next());
			}
			return a;
		}
	}

}