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 maxn = 19;
long long L, R;
long long f[maxn][1 << 8][2520];
long long digit[maxn];
long long dfs(int l, int status, int mod, bool flag) {
  if (l == 0) {
    int lcm = 1;
    for (int i = 2; i <= 9; i++) {
      int cur = (1 << (i - 2)) & status;
      if (cur && mod % i != 0) return 0;
    }
    return 1;
  }
  if (~f[l][status][mod] && !flag) return f[l][status][mod];
  int pos = flag ? digit[l] : 9;
  long long ret = 0;
  for (int i = 0; i <= pos; i++) {
    ret += dfs(l - 1, status | (i - 2 < 0 ? 0 : (1 << (i - 2))),
               (mod * 10 + i) % 2520, flag && (i == pos));
  }
  if (!flag) f[l][status][mod] = ret;
  return ret;
}
long long F(long long x) {
  long long pos = 0;
  while (x) {
    digit[++pos] = x % 10;
    x /= 10;
  }
  return dfs(pos, 0, 0, true);
}
signed main() {
  memset(f, -1, sizeof(f));
  int T;
  scanf("%d", &T);
  while (T--) {
    cin >> L >> R;
    cout << F(R) - F(L - 1) << endl;
  }
  return 0;
}