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 dp[20][50][3000];
int l[20];
map<int, int> m;
void init() {
  memset(dp, -1, sizeof(dp));
  int cnt = 0;
  for (int i = 1; i <= 2520; i++) {
    if (2520 % i == 0) {
      m[i] = ++cnt;
    }
  }
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int lcm(int a, int b) {
  if (b == 0) return a;
  return a * b / gcd(a, b);
}
long long dfs(int pos, long long pre, bool limits, int mod) {
  if (pos == 0) {
    if (pre % mod == 0) {
      return 1;
    } else
      return 0;
  }
  if (dp[pos][m[mod]][pre] != -1 && !limits) return dp[pos][m[mod]][pre];
  int n = limits ? l[pos] : 9;
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    int t = lcm(mod, i);
    ans += dfs(pos - 1, (pre * 10 + i) % 2520, limits && i == l[pos], t);
  }
  if (!limits) dp[pos][m[mod]][pre] = ans;
  return ans;
}
long long solve(long long a) {
  long long t = a;
  int pos = 0;
  while (a) {
    l[++pos] = a % 10;
    a /= 10;
  }
  return dfs(pos, 0, true, 1);
}
int main() {
  init();
  int n;
  long long a, b;
  scanf("%d", &n);
  while (n--) {
    scanf("%lld%lld", &a, &b);
    printf("%lld\n", solve(b) - solve(a - 1));
  }
  return 0;
}