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 M = 300010;
const int mod = 998244353;
int t;
long long l, r;
int a[30];
int mx;
long long dp[20][2530][50];
int b[2530], ID;
int gcd(int x, int y) { return !y ? x : gcd(y, x % y); }
long long DP(int id, int md, int lcm, bool full) {
  if (!id) return md % lcm == 0;
  if (!full && ~dp[id][md][b[lcm]]) return dp[id][md][b[lcm]];
  int r = full ? a[id] : 9;
  long long ans = 0;
  for (int i = 0; i <= r; ++i)
    ans += DP(id - 1, (md * 10 + i) % mx, i ? lcm / gcd(lcm, i) * i : lcm,
              full && i == r);
  if (!full) dp[id][md][b[lcm]] = ans;
  return ans;
}
long long Cal(long long x) {
  int cnt = 0;
  while (x) {
    a[++cnt] = x % 10;
    x /= 10;
  }
  return DP(cnt, 0, 1, true);
}
int main() {
  memset(dp, -1, sizeof(dp));
  mx = 1;
  for (int i = 2; i <= 9; ++i) {
    mx = i * mx / gcd(mx, i);
  }
  for (int i = 1; i <= mx; ++i) {
    if (mx % i == 0) b[i] = ID++;
  }
  std::cin >> t;
  while (t--) {
    std::cin >> l >> r;
    printf("%lld\n", Cal(r) - Cal(l - 1));
  }
  return 0;
}