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 f[20][50][255];
int a[20], b[2550], c[255][10] = {0};
int gcd(int a, int b) {
  while (a ^= b ^= a ^= b %= a)
    ;
  return b;
}
int lc(int a, int b) { return a * b / gcd(a, b); }
long long dfs(int p, int s, int l, bool t) {
  if (!p) return l % s == 0;
  if (!t && f[p][b[s]][l] >= 0) return f[p][b[s]][l];
  int end = t ? a[p] : 9;
  long long ans = 0;
  for (int i = 0; i <= end; i++)
    ans += dfs(p - 1, i ? lc(s, i) : s, p == 1 ? l * 10 + i : c[l][i],
               i == end & t);
  if (!t) f[p][b[s]][l] = ans;
  return ans;
}
long long se(long long x) {
  int po = 0;
  for (; x; x /= 10) a[++po] = x % 10;
  return dfs(po, 1, 0, 1);
}
int main() {
  memset(f, -1, sizeof(f));
  for (int j = 0, i = 1; i <= 2520; i++) b[i] = 2520 % i ? 0 : ++j;
  for (int j = 0; j < 10; j++)
    for (int i = 0; i < 252; i++) c[i][j] = (i * 10 + j) % 252;
  int t;
  long long x, y;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld%lld", &x, &y);
    printf("%lld\n", se(y) - se(x - 1));
  }
}