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 long long read() {
  register long long x = 0, f = 1;
  register char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
  return x * f;
}
long long t, l, r, tot, cnt;
long long f[50 + 5][2520 + 5][50 + 5], in[2520 + 5], a[2520 + 5], bas[2520 + 5];
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long dfs(long long p, long long sum, long long lcm, bool limit) {
  if (!p) return sum % lcm == 0 ? 1 : 0;
  if (!limit && f[p][sum][in[lcm]] != -1) return f[p][sum][in[lcm]];
  long long up = limit ? a[p] : 9, ans = 0;
  for (register long long i = 0; i <= up; ++i) {
    if (i == 0)
      ans += dfs(p - 1, sum * 10 % 2520, lcm, limit && (i == up));
    else
      ans += dfs(p - 1, (sum * 10 + i) % 2520, lcm * i / gcd(lcm, i),
                 limit && (i == up));
  }
  if (!limit) f[p][sum][in[lcm]] = ans;
  return ans;
}
long long calc(long long x) {
  cnt = 0;
  while (x) a[++cnt] = x % 10, x /= 10;
  return dfs(cnt, 0, 1, 1);
}
signed main() {
  t = read();
  memset(f, -1, sizeof(f));
  ;
  for (register long long i = 1; i <= 2520; ++i)
    if (2520 % i == 0) in[i] = (++(tot));
  while (t--) l = read(), r = read(), printf("%lld\n", calc(r) - calc(l - 1));
  return 0;
}