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 max_lcm = 2520;
int dig[25], t, Hash[2525];
long long dp[25][50][2525], a, b;
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 len, int pre_lcm, int pre_num, int flag) {
  if (len == 0) return pre_num % pre_lcm == 0;
  if (!flag && dp[len][Hash[pre_lcm]][pre_num] != -1)
    return dp[len][Hash[pre_lcm]][pre_num];
  int n = flag ? dig[len] : 9;
  long long res = 0;
  for (int i = 0; i <= n; i++) {
    int now_num = (pre_num * 10 + i) % max_lcm;
    int now_lcm = pre_lcm;
    if (i) now_lcm = lcm(pre_lcm, i);
    res += dfs(len - 1, now_lcm, now_num, flag && i == n);
  }
  if (!flag) dp[len][Hash[pre_lcm]][pre_num] = res;
  return res;
}
long long cal(long long num) {
  int len = 0;
  while (num) {
    dig[++len] = num % 10;
    num /= 10;
  }
  return dfs(len, 1, 0, 1);
}
int read() {
  int ret = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
  return ret * f;
}
int main() {
  int cnt = 0;
  for (int i = 1; i <= 2520; i++)
    if (max_lcm % i == 0) Hash[i] = ++cnt;
  t = read();
  memset(dp, -1, sizeof(dp));
  while (t--) {
    scanf("%lld%lld", &a, &b);
    printf("%lld\n", cal(b) - cal(a - 1));
  }
  return 0;
}