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 MOD = 2520;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int b[2610], cnt = 1, size;
void bfs(int now, int sum) {
  if (now == 10) {
    if (b[sum] == 0) {
      b[sum] = cnt;
      cnt++;
    }
    return;
  }
  bfs(now + 1, sum);
  bfs(now + 1, now * sum / gcd(sum, now));
}
int a[25];
long long dp[25][60][3100];
long long dfs(int pos, int state, bool limit, int yet) {
  if (pos == 0) {
    if (yet % state == 0)
      return 1;
    else
      return 0;
  }
  int t = b[state];
  if (!limit && dp[pos][t][yet] != -1) return dp[pos][t][yet];
  int up = limit ? a[pos] : 9;
  long long ans = 0;
  for (int i = 0; i <= up; i++) {
    if (i != 0) {
      int ca = state * i / gcd(state, i);
      ans += dfs(pos - 1, ca, limit && i == up, (yet * 10 + i) % MOD);
    } else {
      ans += dfs(pos - 1, state, limit && i == up, (yet * 10 + i) % MOD);
    }
  }
  if (!limit) dp[pos][t][yet] = ans;
  return ans;
}
long long solve(long long n) {
  int cnt = 0;
  while (n) {
    cnt++;
    a[cnt] = n % 10;
    n = n / 10;
  }
  return dfs(cnt, 1, true, 0);
}
int main(void) {
  int T;
  long long l, r;
  memset(dp, -1, sizeof(dp));
  bfs(1, 1);
  cin >> T;
  while (T--) {
    cin >> l >> r;
    cout << solve(r) - solve(l - 1) << "\n";
  }
  return 0;
}