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 INF = 0x3f3f3f3f;
const double eps = 1E-8;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
const int mod = 2520;
long long dp[20][mod][50];
int idx[mod + 10];
int digit[20];
long long dfs(int pos, int presum, int prelcm, bool bound) {
  if (pos == 0) return presum % prelcm == 0;
  if (!bound && ~dp[pos][presum][idx[prelcm]])
    return dp[pos][presum][idx[prelcm]];
  int nowsum, nowlcm = prelcm;
  long long ans = 0;
  int end = bound ? digit[pos] : 9;
  for (int i = 0; i <= end; i++) {
    nowsum = (presum * 10 + i) % mod;
    if (i) nowlcm = lcm(prelcm, i);
    ans += dfs(pos - 1, nowsum, nowlcm, bound && i == end);
  }
  if (!bound) dp[pos][presum][idx[prelcm]] = ans;
  return ans;
}
long long cal(long long x) {
  int cur = 0;
  while (x) {
    digit[++cur] = x % 10;
    x /= 10;
  }
  return dfs(cur, 0, 1, 1);
}
int T, c;
long long l, r;
int main() {
  scanf("%d", &T);
  c = 0;
  (memset(dp, -1, sizeof(dp)));
  for (int i = 1; i < mod; i++)
    if (mod % i == 0) idx[i] = ++c;
  while (T--) {
    scanf("%I64d%I64d", &l, &r);
    printf("%I64d\n", cal(r) - cal(l - 1));
  }
  return 0;
}