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;
int num[2550], cnt = 0;
int lim[50], lct = 0;
long long f[24][2520][50];
long long l, r, T, ans;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long dp(int pos, int smm, int lcm, bool flag) {
  if (!pos) return (smm % lcm == 0);
  if (!flag && f[pos][smm][num[lcm]] != -1) return f[pos][smm][num[lcm]];
  long long res = 0;
  int limit = 9;
  if (flag) limit = lim[pos];
  for (int i = 0; i <= limit; i++) {
    int psmm = (smm * 10 + i) % 2520;
    int plcm = lcm;
    if (i) {
      plcm = lcm / gcd(lcm, i) * i;
    }
    res += dp(pos - 1, psmm, plcm, flag && i == limit);
  }
  if (!flag) f[pos][smm][num[lcm]] = res;
  return res;
}
long long solve(long long x) {
  lct = 0;
  while (x > 0) {
    lim[++lct] = x % 10;
    x /= 10;
  }
  return dp(lct, 0, 1, 1);
}
int main() {
  int i, j;
  for (int i = 1; i <= 2520; i++) {
    if (2520 % i == 0) num[i] = ++cnt;
  }
  memset(f, -1, sizeof f);
  T = read();
  while (T--) {
    l = read();
    r = read();
    ans = solve(r) - solve(l - 1);
    cout << ans << endl;
  }
  return 0;
}