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 Solution {
	static Scanner sc=new Scanner(System.in);
	static PrintWriter out=new PrintWriter(System.out);
	//Main
	static long dp[][]=new long[19][4];
	static ArrayList<Integer> num;
	static long solve(int i,int cnt,int f) {
		if(i==-1) {
			if(cnt!=0) return 1;
			return 0;
		}
		long sol=0;
		if(f==1) {
			sol+=solve(i-1,cnt,num.get(i)==0?1:0);
			for(int dig=1;dig<=num.get(i);dig++) {
				if(cnt==3) continue;
				sol+=solve(i-1,cnt+1,num.get(i)==dig?1:0);
			}
		}
		else {
			if(dp[i][cnt]!=-1) return dp[i][cnt];
			sol+=solve(i-1,cnt,0);
			for(int dig=1;dig<=9;dig++) {
				if(cnt==3) continue;
				sol+=solve(i-1,cnt+1,0);
			}
		}
		if(f==0) dp[i][cnt]=sol;
		return sol;
	}
	public static void main(String args[]) {
		for(int i=0;i<19;i++) Arrays.fill(dp[i], -1);
		int test=1;
		test=sc.nextInt();
		while(test-->0) {
			//Focus
			long a=sc.nextLong(),b=sc.nextLong();
			a--;
			num=new ArrayList<>();
			while(a>0) {
				num.add((int)(a%10));
				a/=10;
			}
			long ans1=solve(num.size()-1,0,1);
			a=b;
			num=new ArrayList<>();
			while(a>0) {
				num.add((int)(a%10));
				a/=10;
			}
			long ans2=solve(num.size()-1,0,1);
			out.println(ans2-ans1);
		}
		out.flush();
		out.close();
	}
}