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[25][50][2550];
int a[50];
int hh[2550];
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long dfs(int len, int pl, int px, bool l) {
  if (len == -1) return px % pl == 0;
  if (!l && d[len][hh[pl]][px] != -1) return d[len][hh[pl]][px];
  int n = l ? a[len] : 9;
  long long sum = 0;
  for (int i = 0; i <= n; i++) {
    int nowpx = (px * 10 + i) % 2520;
    int nowpl = pl;
    if (i) nowpl = lcm(pl, i);
    sum += dfs(len - 1, nowpl, nowpx, l && i == n);
  }
  if (!l) d[len][hh[pl]][px] = sum;
  return sum;
}
long long CC(long long x) {
  int n = 0;
  while (x) {
    a[n++] = x % 10;
    x /= 10;
  }
  return dfs(n - 1, 1, 0, 1);
}
int main() {
  int u = 0;
  for (int i = 1; i <= 2520; i++) {
    if (2520 % i == 0) hh[i] = ++u;
  }
  int T;
  while (~scanf("%d", &T)) {
    memset(d, -1, sizeof(d));
    while (T--) {
      long long a, b;
      scanf("%I64d%I64d", &a, &b);
      printf("%I64d\n", CC(b) - CC(a - 1));
    }
  }
  return 0;
}