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[20];
long long dp[20][260][2550];
long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); }
long long dfs(long long pos, long long has, long long sum, bool lead,
              bool limit) {
  if (pos == -1) {
    long long t = 1;
    for (long long i = 2; i < 10; i++) {
      if ((has & t) != 0) {
        if (sum % i != 0) return 0;
      }
      t <<= 1;
    }
    return 1;
  }
  if (!limit && !lead && dp[pos][has][sum] != -1) return dp[pos][has][sum];
  long long up = limit ? a[pos] : 9;
  long long ans = 0;
  for (long long i = 0; i <= up; i++) {
    if (i > 1)
      ans += dfs(pos - 1, has | (1 << (i - 2)), (sum * 10 + i) % 2520,
                 lead && i == 0, limit && i == a[pos]);
    else
      ans += dfs(pos - 1, has, (sum * 10 + i) % 2520, lead && i == 0,
                 limit && i == a[pos]);
  }
  if (!limit && !lead) dp[pos][has][sum] = ans;
  return ans;
}
long long solve(long long x) {
  long long pos = 0;
  while (x) {
    a[pos++] = x % 10;
    x /= 10;
  }
  return dfs(pos - 1, 0, 0, true, true);
}
int main() {
  long long li, ri;
  long long t;
  cin >> t;
  memset(dp, -1, sizeof dp);
  while (t--) {
    scanf("%I64d%I64d", &li, &ri);
    long long a = solve(ri);
    long long b = solve(li - 1);
    printf("%I64d\n", a - b);
  }
  return 0;
}