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 long long INF = 9999999999;
long long dp[25][2521][50];
long long a[25];
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long b[3000], k;
long long dfs(long long pos, long long m, bool limit, long long sta) {
  if (pos <= 0) {
    return m % sta == 0;
  }
  if (dp[pos][m][b[sta]] != -1 && !limit) return dp[pos][m][b[sta]];
  long long up = limit ? a[pos] : 9;
  long long ans = 0;
  for (long long i = 0; i <= up; ++i) {
    if (i != 0)
      ans +=
          dfs(pos - 1, (m * 10 + i) % 2520, limit && i == a[pos], lcm(sta, i));
    else
      ans += dfs(pos - 1, (m * 10 + i) % 2520, limit && i == a[pos], sta);
  }
  if (!limit) dp[pos][m][b[sta]] = ans;
  return ans;
}
void pre() {
  k = 0;
  for (long long i = 1; i <= 2520; ++i) {
    if (2520 % i == 0) b[i] = ++k;
  }
}
long long solve(long long x) {
  long long tot = 0;
  while (x) {
    a[++tot] = x % 10;
    x /= 10;
  }
  return dfs(tot, 0, 1, 1);
}
int main() {
  long long t;
  scanf("%lld", &t);
  pre();
  memset(dp, -1, sizeof(dp));
  while (t--) {
    long long x, y;
    scanf("%I64d%I64d", &x, &y);
    long long ans = solve(y) - solve(x - 1);
    printf("%I64d\n", ans);
  }
  return 0;
}