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;
const int Mod = 2520;
int a[20], cod[2525] = {0};
long long dp[22][2522][50];
void init() {
  int tot = 0;
  for (int i = 1; i <= Mod; ++i) {
    if (Mod % i == 0) cod[i] = tot++;
  }
  memset(dp, -1, sizeof(dp));
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int getLcm(int x, int y) { return x / gcd(x, y) * y; }
long long dfs(int len, int prev, int lcm, bool f) {
  if (!len) return prev % lcm ? 0 : 1;
  long long &ans = dp[len][prev][cod[lcm]];
  if (f && ans != -1) return ans;
  int fmax = f ? 9 : a[len - 1];
  long long res = 0;
  for (int i = 0; i <= fmax; ++i) {
    int nprev = ((prev % Mod) * 10 + i) % Mod;
    int nlcm = i ? getLcm(lcm, i) : lcm;
    res += dfs(len - 1, nprev, nlcm, f || (i != fmax));
  }
  if (f) ans = res;
  return res;
}
long long solve(long long x) {
  int cnt = 0;
  while (x) {
    a[cnt++] = x % 10;
    x /= 10;
  }
  return dfs(cnt, 0, 1, false);
}
int main() {
  init();
  int T;
  scanf("%d", &T);
  while (T--) {
    long long a, b;
    scanf("%I64d%I64d", &a, &b);
    printf("%I64d\n", solve(b) - solve(a - 1));
  }
}