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 l, r;
int digit[50];
long long dp[20][2530][50];
const int MOD = 2520;
int Hash[2530];
int gcd_rec[2530][10];
void get_hash() {
  int cnt = 0;
  for (int i = 1; i <= MOD; i++) {
    if (MOD % i == 0) {
      Hash[i] = cnt++;
    }
  }
}
long long gcd(long long a, long long b) {
  if (gcd_rec[a][b] != 0) return gcd_rec[a][b];
  if (!b)
    return gcd_rec[a][b] = a;
  else
    return gcd_rec[a][b] = gcd(b, a % b);
}
long long dfs(int pos, int num, int lcm, int limit) {
  if (pos == -1) return num % lcm == 0;
  if (!limit && dp[pos][num][Hash[lcm]] != -1) return dp[pos][num][Hash[lcm]];
  int up = limit ? digit[pos] : 9;
  long long ans = 0;
  for (int i = 0; i <= up; i++) {
    ans += dfs(pos - 1, (num * 10 + i) % MOD,
               (!i ? lcm : lcm * i / gcd(lcm, i)), (limit && i == up));
  }
  if (!limit) dp[pos][num][Hash[lcm]] = ans;
  return ans;
}
long long solve(long long n) {
  int pos = 0;
  while (n) {
    digit[pos++] = n % 10;
    n /= 10;
  }
  return dfs(pos - 1, 0, 1, 1);
}
void codeforces_55D() {
  int t;
  cin >> t;
  get_hash();
  while (t--) {
    memset(dp, -1, sizeof(dp));
    cin >> l >> r;
    cout << solve(r) - solve(l - 1) << endl;
  }
}
int main() {
  codeforces_55D();
  return 0;
}