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][50][2521];
int a[20];
int m[2521];
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
long long dfs(int pos, int num, int prelcm, bool limit) {
  if (pos == -1) return num % prelcm == 0;
  if (!limit && dp[pos][m[prelcm]][num] != -1) return dp[pos][m[prelcm]][num];
  long long ans = 0;
  int up = limit ? a[pos] : 9;
  for (int i = 0; i <= up; i++) {
    ans += dfs(pos - 1, (num * 10 + i) % 2520, i ? lcm(prelcm, i) : prelcm,
               limit && i == a[pos]);
  }
  if (!limit) dp[pos][m[prelcm]][num] = ans;
  return ans;
}
long long solve(long long n) {
  int c = 0;
  while (n) {
    a[c++] = n % 10;
    n /= 10;
  }
  return dfs(c - 1, 0, 1, true);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  long long l, r;
  int c = 1;
  for (int i = 1; i <= 2520; i++) {
    if (2520 % i == 0) m[i] = c++;
  }
  memset((dp), (-1), sizeof(dp));
  cin >> t;
  while (t--) {
    cin >> l >> r;
    cout << solve(r) - solve(l - 1) << endl;
  }
  return 0;
}