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>
const int MAXP = 2520;
using namespace std;
unsigned long long dp[20][50][MAXP + 10];
int t, s[MAXP + 10], cnt, d[20], len;
unsigned long long l, r, x;
int gcd(int x, int y) {
  if (x < y) swap(x, y);
  if (y == 0) return x;
  return gcd(y, x % y);
}
int get_lcm(int x, int y) {
  if (x < y) swap(x, y);
  if (y == 0) return x;
  return x * y / gcd(x, y);
}
unsigned long long dfs(int len, int prelcm, int presum, int up) {
  unsigned long long res = 0;
  if (len == 0) return (presum % prelcm) == 0;
  if (up == 0 && dp[len][s[prelcm]][presum] != -1)
    return dp[len][s[prelcm]][presum];
  int n;
  if (up == 0)
    n = 9;
  else
    n = d[len];
  for (int i = 0; i <= n; i++) {
    int newlcm = get_lcm(prelcm, i);
    int newsum = (presum * 10 + i) % MAXP;
    res += dfs(len - 1, newlcm, newsum, up && i == n);
  }
  if (!up) dp[len][s[prelcm]][presum] = res;
  return res;
}
unsigned long long query(unsigned long long x) {
  len = 0;
  while (x >= 1) {
    d[++len] = x % 10;
    x = x / 10;
  }
  return dfs(len, 1, 0, 1);
}
int main() {
  memset(dp, -1, sizeof dp);
  for (int i = 1; i <= MAXP; i++)
    if (MAXP % i == 0) s[i] = ++cnt;
  scanf("%d", &t);
  while (t--) {
    scanf("%llu%llu", &l, &r);
    printf("%llu\n", query(r) - query(l - 1));
  }
}