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 int digits[] = {2, 3, 4, 5, 6, 7, 8, 9};
long long tenp[20];
const long long MOD = 2520;
long long dp[20][MOD][1 << 8];
inline int updMask(int mask, int dig) {
  if (dig < 2)
    return mask;
  else
    return mask | (1 << (dig - 2));
}
long long count(long long n) {
  if (n <= 10) return n;
  ostringstream os;
  os << n;
  string s = os.str();
  long long mod = 0;
  long long res = 0;
  int mask = 0;
  for (size_t i = 0; i < s.length(); ++i) {
    int rest = s.length() - i - 1;
    for (char c = '0'; c < s[i]; ++c) {
      res += dp[rest][mod][updMask(mask, c - '0')];
      mod = (mod + tenp[rest]) % MOD;
    }
    if (i == 0) {
      --res;
    }
    mask = updMask(mask, s[i] - '0');
  }
  res += dp[0][mod][mask];
  return res;
}
bool ok(long long n) {
  long long m = n;
  while (m > 0) {
    int d = m % 10;
    if (d > 0 && ((n % d) != 0)) {
      return false;
    }
    m /= 10;
  }
  return true;
}
long long bf(long long n) {
  long long res = 0;
  for (long long i = 1; i <= n; ++i) {
    if (ok(i)) {
      res++;
    }
  }
  return res;
}
int main() {
  cout << fixed;
  cout.precision(16);
  tenp[0] = 1;
  for (int i = 1; i < 20; ++i) {
    tenp[i] = (tenp[i - 1] * 10) % MOD;
  }
  for (int len = 0; len < 20; ++len)
    for (int mod = 0; mod < MOD; ++mod)
      for (int mask = 0; mask < 1 << 8; ++mask) {
        if (len == 0) {
          long long res = 1;
          for (int i = 0; i < 8; ++i)
            if (mask & (1 << i)) {
              if (mod % digits[i] != 0) {
                res = 0;
                break;
              }
            }
          dp[len][mod][mask] = res;
        } else {
          long long res = 0;
          for (int dig = 0; dig <= 9; ++dig) {
            int newMod = (mod + dig * tenp[len - 1]) % MOD;
            int newMask = updMask(mask, dig);
            res += dp[len - 1][newMod][newMask];
          }
          dp[len][mod][mask] = res;
        }
      }
  int t;
  cin >> t;
  while (t--) {
    long long l, r;
    cin >> l >> r;
    long long cl = count(l - 1);
    long long cr = count(r);
    cout << cr - cl << "\n";
  }
  return 0;
}