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;
long long l, r, f[21][mod + 1][50];
long long num[21], mp[mod + 1], cnt;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long dfs(long long len, long long pre, long long mod, long long lim) {
  if (!len) return pre % mod == 0;
  if (!lim && f[len][pre][mp[mod]] != -1) return f[len][pre][mp[mod]];
  long long res = 0;
  long long x = lim ? num[len] : 9;
  for (long long i = 0; i <= x; i++)
    res += dfs(len - 1, (pre * 10 + i) % 2520,
               i == 0 ? mod : mod * i / (gcd(mod, i)), lim && x == i);
  return lim ? res : f[len][pre][mp[mod]] = res;
}
long long solve(long long n) {
  long long len = 0;
  while (n) {
    num[++len] = n % 10;
    n /= 10;
  }
  return dfs(len, 0, 1, 1);
}
signed main() {
  memset(f, -1, sizeof f);
  for (long long i = 1; i <= mod; i++) {
    if (2520 % i == 0) mp[i] = ++cnt;
  }
  long long T = read();
  while (~--T) {
    l = read(), r = read();
    printf("%lld\n", solve(r) - solve(l - 1));
  }
  return 0;
}