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.*;

public class Solution {
	static int[][][] dp;

	public static int solve(String str, int pos, int count, int tight){
		
		if(pos == str.length())	
			return 1;
	
		if(dp[pos][count][tight] != -1)
				return dp[pos][count][tight];

		int choice_till = tight == 0 ? 9 : str.charAt(pos)-'0';

	    	int ans = 0;

			for(int choice = 0; choice <= choice_till; choice++){
				int countUd = count;
				if(choice > 0)
					countUd += 1;

				if(countUd <= 3){
				
					if(choice == choice_till && tight == 1)
						ans += solve(str,pos+1,countUd,1);
					else if(choice == choice_till && tight == 0)
						ans += solve(str,pos+1,countUd,0);
				

					else
						ans += solve(str,pos+1,countUd,0);
				}
			}

				

					
			
		

		return dp[pos][count][tight] = ans;

	}


	public static void main(String[] args) throws Exception {
		// as function is commulatve
		// ans = dp[r] - dp[l-1];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(br.readLine().trim());
		while(t>0){
			String[] in = br.readLine().trim().split(" ");
			dp = new int[30][4][3];
		
			for(int i = 0; i < 30; i++){
				for(int j = 0; j < 4; j++){
				   for(int k = 0; k < 3; k++){
				       dp[i][j][k] = -1;
				   }
				}
			}
			
			int ans = solve(in[1],0,0,1);

		
			

		    
		    char[] l = in[0].toCharArray();
		    
		    int left =  l[l.length-1] -'0';
		    left--;
		    
		   
		   
		    l[l.length-1] =(char)( left + '0');
		 
		   
		    
		    String s = String.valueOf(l);
		    
		    
		    	for(int i = 0; i < 30; i++){
				for(int j = 0; j < 4; j++){
				   for(int k = 0; k < 3; k++){
				       dp[i][j][k] = -1;
				   }
				}
			}
			
			
			ans -= solve(s ,0,0,1);
			System.out.println(ans);
			t--;
		}
		
	}
}