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:
// package Specialist.C2;

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;

public class Classy_Numbers {
	static int[][][] digdp;
	static char[] up;
	public static int solve(int smaller,int rem,int idx) {
		if(rem>3)return 0;
		if(idx==up.length)return 1;
		if(digdp[smaller][rem][idx]!=-1)return digdp[smaller][rem][idx];
		int max=9;
		if(smaller==0)
			max=up[idx]-'0';
		int ans=0;
		for(int i=0;i<=max;i++) {
			int nwsmaller=smaller;
			if(smaller==0&&i<max) 
					nwsmaller=1;
			
				ans+=solve(nwsmaller, rem+((i!=0)?1:0), idx+1);
		}
		return digdp[smaller][rem][idx]=ans;
		
	}
	
	public static int solve(long num) {
		if(num==0)return 1;
		up=(""+num).toCharArray();
		digdp=new int[2][4][20];
		for(int[][] ar:digdp)
			for(int[] a:ar)
				Arrays.fill(a, -1);
		return solve(0,0,0);
		
	}
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
//		System.out.println(solve(100));
		int tc=sc.nextInt();
//		int tc=0;
		while(tc-->0)
		{
			long a=sc.nextLong();
			long b=sc.nextLong();
//			System.out.println(solve(3));
			pw.println(solve(b)-solve(a-1));
			 
		}
		pw.flush();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++) {
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
				if (sb.length() == 18) {
					res += Long.parseLong(sb.toString()) / f;
					sb = new StringBuilder("0");
				}
			}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}

	public static void shuffle(int[] a) {
		int n = a.length;
		for (int i = 0; i < n; i++) {
			int r = i + (int) (Math.random() * (n - i));
			int tmp = a[i];
			a[i] = a[r];
			a[r] = tmp;
		}
	}
}