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 N = 20;
int n, t, cnt, s[N], c[2521], g[N][2525];
long long f[N][200][2521];
long long solve(int x, bool lim, int rest, int mod) {
  if (!x) return !(rest % mod);
  if (!lim && f[x][c[mod]][rest] != -1) return f[x][c[mod]][rest];
  long long res = 0;
  int maxx = lim ? s[x] : 9;
  for (int i = 0; i <= maxx; ++i)
    res += solve(x - 1, lim && i == maxx,
                 x > 1 ? (rest * 10 + i) % 252 : rest * 10 + i, g[i][mod]);
  return lim ? res : f[x][c[mod]][rest] = res;
}
inline long long solve(long long x) {
  cnt = 0;
  while (x) s[++cnt] = x % 10, x /= 10;
  return solve(cnt, true, 0, 1);
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  scanf("%d", &t);
  memset(f, -1, sizeof(f));
  for (int i = 1, rest = -1; i <= 2520; ++i) c[i] = rest += !(2520 % i);
  for (int i = 0; i < 10; ++i) {
    for (int j = 1; j <= 2520; ++j) g[i][j] = i ? i * j / gcd(i, j) : j;
  }
  for (long long l, r; t; --t) {
    scanf("%lld%lld", &l, &r);
    printf("%lld\n", solve(r) - solve(l - 1));
  }
  return 0;
}