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;
const int N = 20;
long long dp[N][50][2600];
int a[N];
int hhash[2600];
const long long mod = 2520;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long dfs(int pos, int presum, int prelcm, bool limit) {
  if (pos == -1) {
    if (presum % prelcm == 0) {
      return 1;
    }
    return 0;
  }
  if (!limit && dp[pos][hhash[prelcm]][presum] != -1)
    return dp[pos][hhash[prelcm]][presum];
  int up = limit ? a[pos] : 9;
  long long ans = 0;
  for (int i = 0; i <= up; i++) {
    long long sum = (presum * 10 + i) % mod;
    long long l = prelcm;
    if (i) {
      l = lcm(prelcm, i);
    }
    ans += dfs(pos - 1, sum, l, limit && i == a[pos]);
  }
  if (!limit) dp[pos][hhash[prelcm]][presum] = ans;
  return ans;
}
long long f(long long x) {
  int i = 0;
  while (x) {
    a[i++] = x % 10;
    x /= 10;
  }
  return dfs(i - 1, 0, 1, 1);
}
int main() {
  int tt;
  scanf("%d", &tt);
  int p = 0;
  for (int i = 1; i <= 2520; i++) {
    if (2520 % i == 0) hhash[i] = p++;
  }
  long long l, r;
  memset(dp, -1, sizeof(dp));
  while (tt--) {
    scanf("%I64d%I64d", &l, &r);
    if (l > r) swap(l, r);
    long long ans1 = f(r);
    long long ans2 = f(l - 1);
    printf("%I64d\n", ans1 - ans2);
  }
}