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 N = 25;
const int LCM = 2520;
int digit[N];
int id[LCM + 1];
long long dp[N][50][LCM + 1];
int Gcd(int x, int y) {
  if (y == 0)
    return x;
  else
    return Gcd(y, x % y);
}
void Init() {
  int cnt = 0;
  for (int i = 1; i <= LCM; i++)
    if (LCM % i == 0) id[i] = cnt++;
  memset(dp, -1, sizeof(dp));
  return;
}
long long Dfs(int len, int lcm, int remain, bool fp) {
  if (len == -1) return remain % lcm == 0 ? 1 : 0;
  if (!fp && dp[len][id[lcm]][remain] != -1) return dp[len][id[lcm]][remain];
  int max = 9;
  if (fp) max = digit[len];
  long long ans = 0;
  for (int i = 0; i <= max; i++) {
    int tlcm = i == 0 ? lcm : lcm / Gcd(lcm, i) * i;
    int tremain = (remain * 10 + i) % LCM;
    ans += Dfs(len - 1, tlcm, tremain, fp && i == max);
  }
  if (!fp) dp[len][id[lcm]][remain] = ans;
  return ans;
}
long long Func(long long x) {
  int cnt = 0;
  while (x) {
    digit[cnt++] = x % 10;
    x /= 10;
  }
  return Dfs(cnt - 1, 1, 0, true);
}
int main() {
  int T;
  scanf("%d", &T);
  Init();
  while (T--) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    printf("%lld\n", Func(b) - Func(a - 1));
  }
  return 0;
}