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>
const int L = 9 * 8 * 7 * 5, maxn = 50;
int t, n;
long long l, r;
char s[50];
long long f[maxn][50][L + 1], a[L + 1];
int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return y ? y / gcd(x, y) * x : x; }
long long dfs(int d, int l, int m, bool b) {
  if (!d) return m % l == 0;
  if (!b && ~f[d][a[l]][m]) return f[d][a[l]][m];
  int mx = b ? s[n - d] - '0' : 9;
  long long res = 0;
  for (int i = 0; i <= mx; ++i) {
    res += dfs(d - 1, lcm(l, i), (m * 10 + i) % L, b && (i == mx));
  }
  if (!b) f[d][a[l]][m] = res;
  return res;
}
long long query(long long x) {
  sprintf(s, "%lld", x);
  n = strlen(s);
  return dfs(n, 1, 0, 1);
}
int main() {
  for (int i = 1; i <= L; ++i)
    if (L % i == 0) a[i] = a[0]++;
  scanf("%d", &t);
  memset(f, -1, sizeof(f));
  while (t--) {
    std::cin >> l >> r;
    printf("%lld\n", query(r) - query(l - 1));
  }
}