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 Max_M = 2520;
unordered_map<int, int> m;
long long dp[50][50][Max_M + 1];
int d[50];
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
int lcm_f(int a, int b) {
  if (a == 0 || b == 0) return (a + b);
  return a * b / gcd(a, b);
}
long long dfs(int pos, int lcm, int num, bool flag) {
  if (pos == -1) {
    return lcm == 0 || num % lcm == 0 ? 1 : 0;
  }
  if (!flag && dp[pos][m[lcm]][num] != -1) {
    return dp[pos][m[lcm]][num];
  }
  int up = flag ? d[pos] : 9;
  long long ret = 0;
  for (int i = 0; i <= up; i++) {
    ret += dfs(pos - 1, lcm_f(i, lcm), (num * 10 + i) % Max_M, flag && i == up);
  }
  if (!flag) {
    dp[pos][m[lcm]][num] = ret;
  }
  return ret;
}
long long solve(long long l) {
  int sz = 0;
  while (l != 0) {
    d[sz++] = l % 10;
    l /= 10;
  }
  long long ret = dfs(sz - 1, 0, 0, true);
  return ret;
}
int main() {
  memset(dp, -1, sizeof dp);
  int cnt = 0;
  for (int i = 1; i <= Max_M; i++) {
    if (Max_M % i == 0) m[i] = ++cnt;
  }
  int t;
  cin >> t;
  for (int _ = 0; _ < t; _++) {
    long long l, r;
    cin >> l >> r;
    cout << solve(r) - solve(l - 1) << endl;
  }
}