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 long long N = 20;
const long long LCM = 2520;
long long f[N][LCM][50];
int tid[LCM + 10];
int b[N];
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
long long lcm(long long x, long long y) { return x * y / gcd(x, y); }
long long work(int len, long long s, long long now, bool flag) {
  if (len == 0) return (s % now) == 0;
  if (flag == false && f[len][s][tid[now]] != -1) return f[len][s][tid[now]];
  long long ans = 0;
  int ed;
  if (flag == true)
    ed = b[len];
  else
    ed = 9;
  for (int i = 0; i <= ed; i++) {
    long long ns = (s * 10 + i) % LCM;
    long long nnow;
    if (i != 0)
      nnow = lcm(now, (long long)i);
    else
      nnow = now;
    ans += work(len - 1, ns, nnow, flag && i == ed);
  }
  if (flag == false) f[len][s][tid[now]] = ans;
  return ans;
}
long long solve(long long x) {
  int len = 0;
  while (x > 0) {
    b[++len] = x % 10;
    x = x / 10;
  }
  return work(len, 0, 1, true);
}
int main() {
  int test;
  scanf("%d", &test);
  memset(f, 255, sizeof(f));
  int s = 1;
  for (int i = 1; i <= LCM; i++)
    if (LCM % i == 0) tid[i] = s++;
  while (test--) {
    long long l, r;
    scanf("%I64d%I64d", &l, &r);
    printf("%I64d\n", solve(r) - solve(l - 1));
  }
  return 0;
}