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;
long long dp[19][2][1 << 8][2520];
bool okey[1 << 8][2520];
int mul[20];
int dig[20];
int n;
long long dfs(int pos, int U, int st, int sum) {
  if (pos == -1) {
    return okey[st][sum];
  }
  long long &ret = dp[pos][U][st][sum];
  if (ret != -1) return ret;
  int end = 9;
  if (U) end = dig[pos];
  ret = 0;
  for (int i = 0; i <= end; i++) {
    int NU = U;
    if (i != end) NU = 0;
    int Nst = st;
    if (i >= 2) Nst |= (1 << (i - 2));
    int Nsum = (sum + i * mul[pos]) % 2520;
    ret += dfs(pos - 1, NU, Nst, Nsum);
  }
  return ret;
}
long long func(long long num) {
  n = 0;
  while (num) {
    dig[n++] = num % 10;
    num /= 10;
  }
  for (int i = 0; i < n; i++) {
    memset(dp[i][1], -1, sizeof(dp[i][1]));
  }
  return dfs(n - 1, 1, 0, 0);
}
void init() {
  for (int i = 0; i < 256; i++) {
    for (int j = 0; j < 2520; j++) {
      okey[i][j] = true;
      for (int d = 2; d <= 9; d++) {
        if (i & (1 << (d - 2))) {
          if (j % d != 0) {
            okey[i][j] = false;
            break;
          }
        }
      }
    }
  }
}
int main() {
  init();
  memset(dp, -1, sizeof(dp));
  mul[0] = 1;
  for (int i = 1; i < 20; i++) {
    mul[i] = (mul[i - 1] * 10) % 2520;
  }
  int T;
  cin >> T;
  while (T--) {
    long long a, b;
    cin >> a >> b;
    cout << func(b) - func(a - 1) << endl;
  }
  return 0;
}