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 lcm[3000], f[20][3000][55], num[55];
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long asd(long long now, long long mod, long long gbs, long long jud) {
  if (now < 0) {
    if (mod % gbs == 0)
      return 1;
    else
      return 0;
  }
  if (jud == 0 && f[now][mod][lcm[gbs]] != -1) {
    return f[now][mod][lcm[gbs]];
  }
  long long mmax = 9, mans = 0;
  if (jud == 1) mmax = num[now];
  for (long long i = 0; i <= mmax; i++) {
    mans += asd(now - 1, (mod * 10 + i) % 2520,
                i != 0 ? i * gbs / gcd(i, gbs) : gbs, jud && i == mmax);
  }
  if (jud == 0) f[now][mod][lcm[gbs]] = mans;
  return mans;
}
long long solve(long long x) {
  long long cnt = 0;
  memset(num, 0, sizeof(num));
  while (x != 0) {
    num[cnt++] = x % 10;
    x /= 10;
  }
  return asd(cnt - 1, 0, 1, 1);
}
int main() {
  int t;
  scanf("%d", &t);
  for (long long i = 1, j = 0; i <= 2520; i++) {
    if (2520 % i == 0) {
      lcm[i] = j++;
    }
  }
  memset(f, -1, sizeof(f));
  while (t--) {
    long long aa, bb;
    scanf("%lld %lld", &aa, &bb);
    long long ans = solve(bb) - solve(aa - 1);
    printf("%lld\n", ans);
  }
  return 0;
}