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 M = 2e5 + 5;
const int inf = 1e9 + 5;
const int mod = 1e9 + 7;
long long dp[20][50][2600];
int s[20];
int a[48] = {1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  12,   14,
             15,  18,  20,  21,  24,  28,  30,  35,  36,  40,  42,   45,
             56,  60,  63,  70,  72,  84,  90,  105, 120, 126, 140,  168,
             180, 210, 252, 280, 315, 360, 420, 504, 630, 840, 1260, 2520};
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long dfs(int pos, int Lcm, int rmd, int lim) {
  int LCM = a[Lcm];
  if (pos <= 0) {
    if (rmd % LCM == 0) return 1;
    return 0;
  }
  if (!lim && dp[pos][Lcm][rmd] != -1) return dp[pos][Lcm][rmd];
  int nn = lim ? s[pos] : 9;
  long long ans = 0;
  for (int i = 0; i <= nn; i++) {
    int _LCM, _rmd;
    if (i == 0) {
      _LCM = LCM;
    } else {
      _LCM = lcm(LCM, i);
    }
    _rmd = (rmd * 10 + i) % 2520;
    int _Lcm = lower_bound(a, a + 48, _LCM) - a;
    ans += dfs(pos - 1, _Lcm, _rmd, lim && i == s[pos]);
  }
  if (!lim) dp[pos][Lcm][rmd] = ans;
  return ans;
}
long long solve(long long x) {
  memset(s, 0, sizeof(s));
  int si = 0;
  while (x > 0) {
    s[++si] = x % 10;
    x /= 10;
  }
  return dfs(si, 0, 0, 1);
}
int main() {
  long long n, m;
  memset(dp, -1, sizeof(dp));
  int _;
  scanf("%d", &_);
  while (_--) {
    scanf("%lld%lld", &n, &m);
    printf("%lld\n", solve(m) - solve(n - 1));
  }
  return 0;
}