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 n, m;
int digit[20];
long long dp[20][50][2520];
int a[48] = {1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  12,   14,
             15,  18,  20,  21,  24,  28,  30,  35,  36,  40,  42,   45,
             56,  60,  63,  70,  72,  84,  90,  105, 120, 126, 140,  168,
             180, 210, 252, 280, 315, 360, 420, 504, 630, 840, 1260, 2520};
int GCD(int a, int b) { return a == 0 ? b : GCD(b % a, a); }
int LCM(int a, int b) { return a * b / GCD(a, b); }
long long DFS(int curPos, int curNum, int lcm, bool limit) {
  if (curPos == -1) return curNum % lcm == 0 ? 1 : 0;
  int t = lower_bound(a, a + 48, lcm) - a;
  if (!limit && dp[curPos][t][curNum] != -1) return dp[curPos][t][curNum];
  int up = limit ? digit[curPos] : 9;
  long long ans = 0;
  for (int i = 0; i <= up; ++i)
    ans += DFS(curPos - 1, (curNum * 10 + i) % 2520,
               (i != 0 ? LCM(lcm, i) : lcm), limit && i == digit[curPos]);
  if (!limit) dp[curPos][t][curNum] = ans;
  return ans;
}
long long Solve(long long x) {
  int k = 0;
  while (x) {
    digit[k++] = x % 10;
    x /= 10;
  }
  return DFS(k - 1, 0, 1, true);
}
int main() {
  int test;
  scanf("%d", &test);
  memset(dp, -1, sizeof(dp));
  while (test--) {
    scanf("%lld%lld", &n, &m);
    printf("%lld\n", Solve(m) - Solve(n - 1));
  }
  return 0;
}