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 long long mod = 2520;
const long long INF = numeric_limits<long long>::max();
void read(long long &x) {
  x = 0;
  char ch = getchar();
  long long f = 1;
  while (!isdigit(ch)) (ch == '-' ? f = -1 : 0), ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
long long f[30][2523][50];
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
long long LCM(long long x, long long y) { return x / gcd(x, y) * y; }
long long st[30], id[3000];
long long dfs(long long pos, long long reminder, long long lcm, long long _zero,
              long long bounded) {
  if (pos == 0) {
    return reminder % lcm == 0;
  }
  if (!_zero && !bounded && f[pos][reminder][id[lcm]] != -1)
    return f[pos][reminder][id[lcm]];
  long long ans = 0;
  long long ed = bounded ? st[pos] : 9;
  for (long long i = 0; i <= ed; ++i)
    if (i == 0) {
      if (_zero)
        ans += dfs(pos - 1, reminder, lcm, 1, bounded && i == ed);
      else
        ans += dfs(pos - 1, reminder * 10 % mod, lcm, 0, bounded && i == ed);
    } else
      ans += dfs(pos - 1, (reminder * 10 + i) % mod, LCM(lcm, i), 0,
                 bounded && i == ed);
  if (!_zero && !bounded) f[pos][reminder][id[lcm]] = ans;
  return ans;
}
long long solve(long long n) {
  long long tp = 0;
  while (n) {
    st[++tp] = n % 10;
    n /= 10;
  }
  return dfs(tp, 0, 1, 1, 1);
}
long long T, l, r;
signed main() {
  memset(f, -1, sizeof(f));
  long long R = 1 << 10;
  --R;
  long long cnt = 0;
  for (long long s = 2; s <= R; ++s) {
    long long tmp = 1;
    for (long long j = 1; j <= 9; ++j)
      if (s & (1 << j)) tmp = LCM(tmp, j);
    if (!id[tmp]) id[tmp] = ++cnt;
  }
  read(T);
  while (T--) {
    read(l);
    read(r);
    solve(l - 1);
    solve(r);
    printf("%lld\n", solve(r) - solve(l - 1));
  }
  return 0;
}