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 f[20][55][2600], c[20];
long long l[5005], tot = 0;
void Turn(long long k) {
  memset(c, 0, sizeof(c));
  while (k) c[++c[0]] = k % 10, k /= 10;
  return;
}
int gcd(int x, int y) { return x % y ? gcd(y, x % y) : y; }
long long Search(int x, int lcm, int num, bool flag) {
  if (!x && num % lcm == 0)
    return 1;
  else if (!x)
    return 0;
  if (!flag && ~f[x][l[lcm]][num]) return f[x][l[lcm]][num];
  int k = flag ? c[x] : 9;
  long long s = 0;
  for (int i = 0; i <= k; i++) {
    s += Search(x - 1, i ? lcm * i / gcd(lcm, i) : lcm, (num * 10 + i) % 2520,
                flag && i == k);
  }
  if (!flag) f[x][l[lcm]][num] = s;
  return s;
}
long long Calc(long long k) {
  Turn(k);
  return Search(c[0], 1, 0, 1);
}
int main() {
  for (int i = 1; i <= 2520; i++)
    if (2520 % i == 0) l[i] = ++tot;
  memset(f, -1, sizeof(f));
  long long x, y;
  int T;
  cin >> T;
  while (T--) {
    cin >> x >> y;
    cout << Calc(y) - Calc(x - 1) << endl;
  }
  return 0;
}