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 int L = 20;
int T, d[L], len = 0, tot = 0;
long long l, r, dp[L][50][2530];
int pos[2530];
int gcd(int a, int b) {
  while (b ^= a ^= b ^= a %= b)
    ;
  return a;
}
long long dfs(int p, bool full, int lcm, int mod) {
  if (!(~p)) {
    return mod % lcm == 0;
  }
  if (!full && ~dp[p][pos[lcm]][mod]) return dp[p][pos[lcm]][mod];
  long long res = 0;
  for (int i = 0; i <= (full ? d[p] : 9); ++i) {
    if (i == 1 || i == 0)
      res += dfs(p - 1, full && i == d[p], lcm, (mod * 10 + i) % 2520);
    else
      res += dfs(p - 1, full && i == d[p], lcm / gcd(lcm, i) * i,
                 (mod * 10 + i) % 2520);
  }
  if (!full) dp[p][pos[lcm]][mod] = res;
  return res;
}
long long calc(long long x) {
  for (int i = 0; i <= 19; ++i) d[i] = x % 10, x /= 10;
  return dfs(19, 1, 1, 0);
}
void print(int l, int r) {
  for (int i = l; i <= r; ++i) {
    bool flag = false;
    int t = i;
    while (t) {
      if (t % 10 && i % (t % 10)) {
        flag = true;
        break;
      }
      t /= 10;
    }
    if (!flag) printf("%d\n", i);
  }
}
int main() {
  scanf("%d", &T);
  for (int i = 1; i <= 2520; ++i)
    if (2520 % i == 0) pos[i] = ++tot;
  memset(dp, -1, sizeof(dp));
  while (T--) {
    scanf("%lld%lld", &l, &r);
    printf("%lld\n", calc(r) - calc(l - 1));
  }
  return 0;
}