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 hashh[2599];
long long num[25], dp[25][2599][60];
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
long long Lcm(long long x, long long y) { return x * y / gcd(x, y); }
long long dfs(long long len, long long mod, long long lcm, long long limit) {
  long long sum = 0;
  if (len <= 0) return (mod % lcm) == 0;
  if (!limit && dp[len][mod][hashh[lcm]] != -1) return dp[len][mod][hashh[lcm]];
  long long up = limit ? num[len] : 9;
  for (int i = 0; i <= up; i++) {
    sum += dfs(len - 1, (mod * 10 + i) % 2520, i ? Lcm(lcm, i) : lcm,
               (i == up) && limit);
  }
  if (!limit) dp[len][mod][hashh[lcm]] = sum;
  return sum;
}
long long solve(long long number) {
  long long len = 0;
  while (number) {
    num[++len] = number % 10;
    number /= 10;
  }
  return dfs(len, 0, 1, true);
}
void init() {
  memset(dp, -1, sizeof(dp));
  long long a = 0;
  for (int i = 1; i * i < 2520; i++) {
    if (2520 % i == 0) {
      hashh[i] = a++;
      hashh[2520 / i] = a++;
    }
  }
}
int main() {
  long long a, b;
  init();
  int n;
  cin >> n;
  while (n--) {
    cin >> a >> b;
    cout << solve(b) - solve(a - 1) << endl;
  }
}