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 C {
	static FastReader sc=null;
	static long dp[][][];
	static int n;
	static char line[];
	
			
	public static void main(String[] args) {
		sc=new FastReader();
		PrintWriter out=new PrintWriter(System.out);
		int t=sc.nextInt();
		while(t-->0) {
			long li=sc.nextLong();
			li--;
			char l[]=String.valueOf(li).toCharArray(),r[]=sc.next().toCharArray();
			long left=check(l),right=check(r);
			out.println(right-left);
		}
		out.close();
		
		
	}
	static long check(char l[]) {
		
		n=l.length;
		line=l;
		dp=new long[n][4][2];
		for(int i=0;i<n;i++)
			for(int j=0;j<4;j++)Arrays.fill(dp[i][j], -1);
		
		return (go(0,0,1)-1);
		
	}
	static long go(int pos,int nonZeroDigits,int state) {
		if(nonZeroDigits>3)return 0;
		
		if(pos==n) {
			return 1;
		}
		
		if(dp[pos][nonZeroDigits][state]!=-1)return dp[pos][nonZeroDigits][state];
		
		int lim=(state==1?line[pos]-'0':9);
		
		long ans=0;
		for(int i=0;i<=lim;i++) {
			int curr=(i==lim)?1:0;
			
			ans+=go(pos+1,nonZeroDigits+ (i!=0?1:0),(state&curr));
			
		}
		
		return dp[pos][nonZeroDigits][state]=ans;
		
	}
	
	
	static int[] ruffleSort(int a[]) {
		ArrayList<Integer> al=new ArrayList<>();
		for(int i:a)al.add(i);
		Collections.sort(al);
		for(int i=0;i<a.length;i++)a[i]=al.get(i);
		return a;
	}
	static void print(int a[]) {
		for(int e:a) {
			System.out.print(e+" ");
		}
		System.out.println();
	}
	
	static class FastReader{
		
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		String next() {
			while(!st.hasMoreTokens())
				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());
		}
		
		int[] readArray(int n) {
			int a[]=new int[n];
			for(int i=0;i<n;i++)a[i]=sc.nextInt();
			return a;
		}
	}
}