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;
inline int gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
inline int getlcm(long long a, long long b) { return a / gcd(a, b) * b; }
const int p = 2520;
long long len, m, n, a[20];
long long f[20][p + 1][50];
int lcm[p + 1];
long long dfs(long long pos, long long rem, int k, long long lim) {
  if (pos == -1) return rem % k == 0;
  auto &re = f[pos][rem][lcm[k]];
  if (!lim && ~re) return re;
  long long res = 0, up = lim ? a[pos] : 9;
  long long temp;
  for (int i = 0; i <= up; i++) {
    if (i)
      temp = getlcm(k, i);
    else
      temp = k;
    res += dfs(pos - 1, (rem * 10 + i) % p, temp, lim && i == up);
  }
  if (!lim) re = res;
  return res;
}
long long dp(long long x) {
  len = 0;
  while (x) a[len++] = x % 10, x /= 10;
  return dfs(len - 1, 0, 1, 1);
}
int main() {
  memset(f, -1, sizeof f);
  for (int i = 1, cnt = 1; i <= p; i++)
    if (p % i == 0) lcm[i] = cnt++;
  int T;
  cin >> T;
  while (T--) {
    cin >> n >> m;
    printf("%lld\n", dp(m) - dp(n - 1));
  }
}