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 MAXN = 2520 + 5;
int ha[MAXN];
long long dp[20][2520 + 5][50];
int d[20];
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long dfs(int len, int sum, int m, bool flag) {
  if (len == 0) return sum % m ? 0 : 1;
  if (!flag && dp[len][sum][ha[m]] != -1) return dp[len][sum][ha[m]];
  int maxx = flag ? d[len] : 9;
  long long ans = 0;
  for (int i = 0; i <= maxx; i++) {
    ans += dfs(len - 1, (sum * 10 + i) % 2520, i == 0 ? m : lcm(m, i),
               flag && (i == d[len]));
  }
  if (!flag) dp[len][sum][ha[m]] = ans;
  return ans;
}
long long cal(long long x) {
  int len = 0;
  while (x) {
    d[++len] = x % 10;
    x /= 10;
  }
  return dfs(len, 0, 1, true);
}
int main() {
  memset(dp, -1, sizeof dp);
  int cnt = 0;
  for (int i = 1; i * i <= 2520; i++) {
    if (2520 % i == 0) {
      ha[i] = cnt++;
      if (i * i != 2520) ha[2520 / i] = cnt++;
    }
  }
  long long l, r;
  int t;
  cin >> t;
  while (t--) {
    cin >> l >> r;
    long long ans = cal(r) - cal(l - 1);
    cout << ans << endl;
  }
}