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;
long long num[25], f[25][2530][50];
int book[2530], cur;
inline int gcd(int x, int y) { return x % y ? gcd(y, x % y) : y; }
inline int lcm(int x, int y) {
  if (!y) return x;
  return x * y / gcd(x, y);
}
long long dfs(int pos, int mod, int _lcm, int limit) {
  if (!pos) return mod % _lcm == 0;
  if (!limit && ~f[pos][mod][book[_lcm]]) return f[pos][mod][book[_lcm]];
  long long ret = 0, maxx = limit ? num[pos] : 9;
  for (int i = 0; i <= maxx; i++)
    ret +=
        dfs(pos - 1, (mod * 10 + i) % 2520, lcm(_lcm, i), limit && (i == maxx));
  if (!limit) f[pos][mod][book[_lcm]] = ret;
  return ret;
}
long long solve(long long x) {
  int len = 0;
  while (x) num[++len] = x % 10, x /= 10;
  return dfs(len, 0, 1, 1);
}
int main() {
  std::ios::sync_with_stdio(0);
  memset(f, -1, sizeof(f));
  for (int i = 1; i <= 2520; i++)
    if (2520 % i == 0) book[i] = ++cur;
  int q;
  cin >> q;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    cout << solve(b) - solve(a - 1) << endl;
  }
  return 0;
}