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