Problem: Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just count the quantity of beautiful numbers in given ranges.

Input

The first line of the input contains the number of cases t (1 ≤ t ≤ 10). Each of the next t lines contains two natural numbers li and ri (1 ≤ li ≤ ri ≤ 9 ·1018).

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).

Output

Output should contain t numbers — answers to the queries, one number per line — quantities of beautiful numbers in given intervals (from li to ri, inclusively).

Examples

Input

1
1 9


Output

9


Input

1
12 15


Output

2

Solution (in JAVA):

Solution:
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	static Scanner sc = new Scanner(System.in);
	static final int MAXN = 25;
	static final int MOD = 2520;
	static long[][][] f = new long[20][2600][50];
	static long[] bit = new long[20];
	static int[] mp = new int[3000];
	static int gcd(int x, int y){
		return y > 0 ? gcd(y, x % y) : x;
	}
	static int lcm(int x, int y){
		if(x == 0 || y == 0) return x | y;
		return x * y / gcd(x, y);
	}
	static long dfs(int now, int val, int pro, int lim){
		if(now == 0) return val % pro == 0 ? 1 : 0;
		if(lim == 0 && f[now][val][mp[pro]] != -1) return f[now][val][mp[pro]];
		long up = lim > 0 ? bit[now] : 9, res = 0;
		for(int i = 0; i <= up; i++)
			res += dfs(now - 1, (val*10+i)%MOD, lcm(pro, i), lim>0&&i==bit[now]?1:0);
		if(lim == 0) f[now][val][mp[pro]] = res;
		return res;
	}
	static long solve(long n){
		int m = 0;
		for(; n > 0; n /= 10L) bit[++m] = n % 10L;	
		return dfs(m, 0, 1, 1);
	}
	static void run(){
		long x = sc.nextLong(), y = sc.nextLong();
		System.out.println(solve(y) - solve(x - 1L));
	}
	public static void main(String[] args) {
		int sz = 0;
		for(int i = 1; i <= MOD; i++)
			if(MOD % i == 0) mp[i] = ++sz;
		for(int i = 0; i < 20; i++)
		for(int j = 0; j < 2600; j++)
		for(int k = 0; k < 50; k++)
			f[i][j][k] = -1;
		int T; for(T=sc.nextInt(); T-->0;) run();
	}
}