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 a[21], n, lsh[2521], dp[21][2521][51];
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long DP(long long pos, long long limit, long long sum, long long mod) {
  if (!pos) return sum % mod == 0;
  if (!limit && ~dp[pos][sum][lsh[mod]]) return dp[pos][sum][lsh[mod]];
  long long up = limit ? a[pos] : 9, ans = 0;
  for (long long i = 0; i <= up; ++i)
    ans += DP(pos - 1, limit && i == up, (sum * 10 + i) % 2520,
              i ? lcm(i, mod) : mod);
  if (!limit) dp[pos][sum][lsh[mod]] = ans;
  return ans;
}
long long calc(long long up) {
  n = 0;
  while (up) a[++n] = up % 10, up /= 10;
  return DP(n, 1, 0, 1);
}
int main() {
  memset(dp, -1, sizeof dp);
  long long s = 0;
  for (long long i = 1; i <= 2520; ++i)
    if (2520 % i == 0) lsh[i] = ++s;
  long long T;
  scanf("%lld", &T);
  while (T-- > 0) {
    long long l, r;
    scanf("%lld %lld", &l, &r);
    printf("%lld\n", calc(r) - calc(l - 1));
  }
  return 0;
}