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 d[100], n, to[2525];
long long f[25][2520][50], ans1, a, b, ans2;
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
void dat() {
  int ps = 0;
  for (int i = 1; i <= 2520; i++) {
    if (2520 % i == 0) {
      to[i] = ps++;
    }
  }
}
long long o_o(int pos, int mod, int t, int limit) {
  if (pos < 1) return mod % t == 0;
  if (limit && f[pos][mod][to[t]] != -1) return f[pos][mod][to[t]];
  int end = limit ? 9 : d[pos];
  long long ret = 0;
  for (int i = 0; i <= end; i++) {
    int zlcm;
    if (i == 0)
      zlcm = t;
    else
      zlcm = lcm(t, i);
    ret += o_o(pos - 1, (mod * 10 + i) % 2520, zlcm, limit || (i != end));
  }
  if (limit) {
    f[pos][mod][to[t]] = ret;
  }
  return ret;
}
int chai(long long a) {
  int tot = 0;
  while (a > 0) {
    d[++tot] = a % 10;
    a = a / 10;
  }
  return tot;
}
void readdata() {
  scanf("%lld", &n);
  dat();
  memset(f, -1, sizeof(f));
  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", &a, &b);
    ans2 = 0;
    ans1 = 0;
    ans1 = o_o(chai(a - 1), 0, 1, 0);
    ans2 = o_o(chai(b), 0, 1, 0);
    printf("%lld\n", ans2 - ans1);
  }
}
int main() { readdata(); }