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>
const double pi = 4.0 * atan(1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 200005;
const int maxm = 40000;
const int mod = 2520;
using namespace std;
long long int n, m, tol;
int digit[20];
long long int dp[20][50][2600];
int id[2600];
void init() {
  memset(dp, -1, sizeof dp);
  memset(id, 0, sizeof id);
}
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
void handle() {
  tol = 1;
  for (int i = 1; i <= mod; i++) {
    if (mod % i == 0) {
      id[i] = tol++;
    }
  }
}
long long int dfs(int pos, int presum, int prelcm, int limit) {
  if (pos == 0) return presum % prelcm == 0 ? 1 : 0;
  if (!limit && dp[pos][id[prelcm]][presum] != -1)
    return dp[pos][id[prelcm]][presum];
  int up = limit ? digit[pos] : 9;
  long long int ans = 0;
  for (int i = 0; i <= up; i++) {
    int nowsum = (presum * 10 + i) % mod;
    int nowlcm = i ? lcm(prelcm, i) : prelcm;
    ans += dfs(pos - 1, nowsum, nowlcm, limit && i == digit[pos]);
  }
  if (!limit) dp[pos][id[prelcm]][presum] = ans;
  return ans;
}
long long int solve(long long int x) {
  memset(digit, 0, sizeof digit);
  int pos = 1;
  while (x) {
    digit[pos++] = x % 10;
    x /= 10;
  }
  return dfs(pos - 1, 0, 1, true);
}
int main() {
  int T;
  scanf("%d", &T);
  init();
  handle();
  while (T--) {
    scanf("%lld%lld", &n, &m);
    long long int ans = solve(m) - solve(n - 1);
    printf("%lld\n", ans);
  }
  return 0;
}