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;
double eps = 1e-8;
long long mod = 998244353;
const int INF = 0x3f3f3f3f, inf = 0x3f3f3f3f;
const int MAXN = 2e3 + 10;
const int N = 1e3 + 10;
int num[2550], cnt = 0;
int lim[50], lct = 0;
long long f[24][2520][50];
long long n, m;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long dp(int pos, int smm, int lcm, bool flag) {
  if (pos == 0) return smm % lcm == 0;
  if (flag == 0 && 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 == 0) f[pos][smm][num[lcm]] = res;
  return res;
}
long long divi(long long x) {
  lct = 0;
  while (x) {
    lim[++lct] = x % 10;
    x /= 10;
  }
  return dp(lct, 0, 1, 1);
}
int main() {
  int t;
  for (int i = 1; i <= 2520; i++) {
    if (2520 % i == 0) num[i] = ++cnt;
  }
  memset(f, -1, sizeof(f));
  scanf("%d", &t);
  while (t--) {
    scanf("%I64d%I64d", &n, &m);
    printf("%I64d\n", divi(m) - divi(n - 1));
  }
}