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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int LCM = 2520;
int a[20];
int b[LCM + 5];
long long dp[20][50][LCM + 5];
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
long long dfs(int i, int prelcm, int presum, bool e) {
  if (i < 0) return presum % prelcm == 0;
  if (!e && dp[i][b[prelcm]][presum] != -1) return dp[i][b[prelcm]][presum];
  int u = e ? a[i] : 9;
  long long res = 0;
  for (int d = 0; d <= u; ++d) {
    int nowlcm = prelcm, nowsum = (presum * 10 + d) % LCM;
    if (d) nowlcm = (prelcm * d) / gcd(prelcm, d);
    res += dfs(i - 1, nowlcm, nowsum, e && d == u);
  }
  return e ? res : dp[i][b[prelcm]][presum] = res;
}
long long solve(long long n) {
  int i = 0;
  while (n) {
    a[i++] = n % 10;
    n /= 10;
  }
  return dfs(i - 1, 1, 0, 1);
}
int main() {
  long long n, l, r;
  int cnt = 0;
  for (int i = 1; i <= LCM; ++i)
    if (LCM % i == 0) b[i] = cnt++;
  memset(dp, -1, sizeof(dp));
  while (scanf("%I64d", &n) == 1) {
    while (n--) {
      scanf("%I64d%I64d", &l, &r);
      long long a = solve(l - 1);
      long long b = solve(r);
      cout << b - a << endl;
    }
  }
  return 0;
}