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;
template <typename T>
inline T _min(T A, T B) {
  return A < B ? A : B;
}
template <typename T>
inline T _max(T A, T B) {
  return A > B ? A : B;
}
template <typename T>
inline char MIN(T& A, T B) {
  return A > B ? (A = B, 1) : 0;
}
template <typename T>
inline char MAX(T& A, T B) {
  return A < B ? (A = B, 1) : 0;
}
template <typename T>
inline void _swap(T& A, T& B) {
  A ^= B ^= A ^= B;
}
template <typename T>
inline T read(T& x) {
  x = 0;
  int f = 0;
  char c;
  while (!isdigit(c = getchar()))
    if (c == '-') f = 1;
  while (isdigit(c)) x = x * 10 + (c & 15), c = getchar();
  return f ? x = -x : x;
}
const int P = 2520;
int ha[3000], tot;
long long f[20][P][50], b[20], L, R;
int k, T;
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
long long dp(int len, int mod, int lcm, int limit) {
  if (!len) return mod % lcm == 0;
  if (!limit && ~f[len][mod][ha[lcm]]) return f[len][mod][ha[lcm]];
  int num = limit ? b[len] : 9;
  long long ret = dp(len - 1, mod * 10 % P, lcm, limit && !b[len]);
  for (register int i = 1; i <= num; ++i)
    ret += dp(len - 1, (mod * 10 + i) % P, lcm * i / gcd(lcm, i),
              limit && i == num);
  return limit ? ret : f[len][mod][ha[lcm]] = ret;
}
inline long long solve(long long x) {
  k = 0;
  while (x) b[++k] = x % 10, x /= 10;
  return dp(k, 0, 1, 1) - 1;
}
int main() {
  for (register int i = 1; i <= 8; i *= 2)
    for (register int j = 1; j <= 9; j *= 3)
      for (register int k = 1; k <= 5; k *= 5)
        for (register int l = 1; l <= 7; l *= 7) ha[i * j * k * l] = ++tot;
  memset(f, -1, sizeof f);
  read(T);
  while (T--) read(L), read(R), printf("%I64d\n", solve(R) - solve(L - 1));
  return 0;
}