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[20][1 << 8][2520];
int digit[20];
const int mod = 2520;
long long dfs(int len, int mask, int num, bool fp) {
  if (!len) {
    for (int i = 0; i < 8; i++)
      if (mask & (1 << i) && num % (i + 2) != 0) return 0;
    return 1;
  }
  if (!fp && dp[len][mask][num] != -1) return dp[len][mask][num];
  int fpmax = fp ? digit[len] : 9;
  long long ret = 0;
  for (int i = 0; i <= fpmax; i++) {
    ret += dfs(len - 1, i < 2 ? mask : mask | 1 << (i - 2),
               (num * 10 + i) % mod, fp && i == fpmax);
  }
  if (!fp) dp[len][mask][num] = ret;
  return ret;
}
long long f(long long n) {
  int len = 0;
  while (n) {
    digit[++len] = n % 10;
    n /= 10;
  }
  return dfs(len, 0, 0, true);
}
int main() {
  memset(dp, -1, sizeof(dp));
  int T;
  long long a, b;
  scanf("%d", &T);
  while (T--) {
    scanf("%I64d%I64d", &a, &b);
    printf("%I64d\n", f(b) - f(a - 1));
  }
  return 0;
}