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 void read(T& x) {
  char ch = getchar();
  bool flag = false;
  x = 0;
  while (!isdigit(ch)) flag |= (ch == '-'), ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  if (flag) x = -x;
}
const long long Mod = 2520;
const int N = 20, M = 2525;
int Hash[M];
long long dp[N][Mod][50];
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
vector<int> dig;
long long dfs(int pos, int st, int comm, bool limit) {
  if (pos == -1) return st % comm == 0;
  if (!limit && ~dp[pos][st][Hash[comm]]) return dp[pos][st][Hash[comm]];
  int maxn = limit ? dig[pos] : 9;
  long long res = 0;
  for (int i = 0; i <= maxn; i++) {
    if (!i)
      res += dfs(pos - 1, (st * 10 + i) % Mod, comm, limit && i == maxn);
    else
      res +=
          dfs(pos - 1, (st * 10 + i) % Mod, lcm(comm, i), limit && i == maxn);
  }
  if (!limit) dp[pos][st][Hash[comm]] = res;
  return res;
}
long long solve(long long x) {
  dig.clear();
  while (x) {
    dig.push_back(x % 10);
    x /= 10;
  }
  return dfs(dig.size() - 1, 0, 1, true);
}
int main() {
  int cnt = 0;
  for (int i = 1; i <= Mod; i++) {
    if (Mod % i == 0) Hash[i] = ++cnt;
  }
  memset(dp, -1, sizeof(dp));
  int T;
  scanf("%d", &T);
  while (T--) {
    long long l, r;
    scanf("%lld%lld", &l, &r);
    printf("%lld\n", solve(r) - solve(l - 1));
  }
  return 0;
}