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 = 2e5 + 5;
const int MAXM = 1e6 + 5;
long long n, m;
long long dp[20][50][2520];
long long digit[105];
long long mod = 0;
int cnt = 0;
inline long long read() {
  long long X = 0, w = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') X = X * 10 + c - '0', c = getchar();
  return X * w;
}
int GCD(int a, int b) { return b == 0 ? a : GCD(b, a % b); }
int LCM(int a, int b) { return a / GCD(a, b) * b; }
int tong[2521] = {0};
void init() {
  for (int i = 1; i <= 2520; i++) {
    if (2520 % i == 0) {
      tong[i] = ++cnt;
    }
  }
}
long long dfs(int len, int lcm, int st, bool limit) {
  if (len == 0) {
    return st % lcm == 0;
  }
  if (!limit && ~dp[len][tong[lcm]][st]) return dp[len][tong[lcm]][st];
  int maxx = limit ? digit[len] : 9;
  long long ans = 0;
  for (int i = 0; i <= maxx; i++) {
    int L = (i == 0 ? lcm : LCM(lcm, i));
    ans += dfs(len - 1, L, (st * 10 + i) % 2520, limit && i == maxx);
  }
  if (!limit) dp[len][tong[lcm]][st] = ans;
  return ans;
}
long long solve(long long num) {
  int k = 0;
  while (num) {
    digit[++k] = num % 10;
    num /= 10;
  }
  return dfs(k, 1, 0, 1);
}
int main() {
  long long t;
  t = read();
  init();
  memset(dp, -1, sizeof dp);
  while (t--) {
    long long a, b;
    a = read(), b = read();
    printf("%I64d\n", solve(b) - solve(a - 1));
  }
}