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;
using ll = long long;
ll A[19], cnt, dp[19][4][3][2][2][504][2];
const int p3[]{1, 3, 9};
ll dfs(int pos, int level2, int level3, int level5, int level7, int sum,
       bool limit) {
  ll ans = 0;
  if (dp[pos][level2][level3][level5][level7][sum][limit] != -1)
    return dp[pos][level2][level3][level5][level7][sum][limit];
  for (int v = 0; v <= (limit ? A[pos] : 9); ++v) {
    int l2 = level2, l3 = level3, l5 = level5, l7 = level7;
    int cur = (sum * 10 + v) % 504;
    if (v == 2) l2 = max(l2, 1);
    if (v == 3) l3 = max(l3, 1);
    if (v == 4) l2 = max(l2, 2);
    if (v == 5) l5 = 1;
    if (v == 6) l2 = max(l2, 1), l3 = max(l3, 1);
    if (v == 7) l7 = 1;
    if (v == 8) l2 = 3;
    if (v == 9) l3 = 2;
    if (pos == cnt - 1)
      ans += cur % (1 << l2) == 0 && cur % p3[l3] == 0 &&
             cur % (l7 ? 7 : 1) == 0 && (!l5 || v == 5 || v == 0);
    else
      ans += dfs(pos + 1, l2, l3, l5, l7, cur, limit && v == A[pos]);
  }
  if (!limit) dp[pos][level2][level3][level5][level7][sum][limit] = ans;
  return ans;
}
ll f(ll x) {
  if (x == 0) return 1;
  cnt = 0;
  while (x) A[cnt++] = x % 10, x /= 10;
  reverse(A, A + cnt);
  memset(dp, -1, sizeof(dp));
  return dfs(0, 0, 0, 0, 0, 0, true);
}
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    ll x, y;
    cin >> x >> y;
    ll l = f(x - 1), r = f(y);
    cout << r - l << "\n";
  }
  return 0;
}