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 mod = 2520;
int t, dig[20], fac[50], d[50][10], num[mod + 5];
long long dp[20][50][mod + 5];
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
long long dfs(int pos, int beishu, int yu, bool limit) {
  if (pos == 0) {
    return yu % fac[beishu] == 0;
  }
  if (!limit && dp[pos][beishu][yu] != -1) {
    return dp[pos][beishu][yu];
  }
  long long ans = 0;
  int ed = limit ? dig[pos] : 9;
  for (int i = 0; i <= ed; i++) {
    ans += dfs(pos - 1, d[beishu][i], (yu * 10 + i) % mod, limit && i == ed);
  }
  if (!limit) {
    dp[pos][beishu][yu] = ans;
  }
  return ans;
}
long long work(long long x) {
  int cnt = 0;
  while (x > 0) {
    dig[++cnt] = x % 10;
    x = x / 10;
  }
  return dfs(cnt, 1, 0, 1);
}
void init() {
  memset(dp, -1, sizeof(dp));
  int tot = 0;
  for (int i = 1; i <= mod; i++) {
    if (mod % i == 0) {
      fac[++tot] = i;
      num[i] = tot;
    }
  }
  for (int i = 1; i <= tot; i++) {
    d[i][0] = i;
    for (int j = 1; j <= 9; j++) {
      d[i][j] = num[lcm(fac[i], j)];
    }
  }
}
int main() {
  init();
  scanf("%d", &t);
  while (t--) {
    long long a, b;
    scanf("%I64d %I64d", &a, &b);
    printf("%I64d\n", work(b) - work(a - 1));
  }
  return 0;
}