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;
int pos[2600], tra[50][50], dig[30], top;
vector<int> pak;
long long f[30][50][2600];
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
long long dfs(int stp, int LCM, int MOD, int LIM) {
  long long &res = f[stp][LCM][MOD];
  if (stp == 0) {
    return MOD % pak[LCM] == 0;
  } else if (!LIM && res != -1) {
    return res;
  } else {
    long long sum = 0;
    for (int i = (LIM ? dig[stp] : 9); i >= 0; --i) {
      sum += dfs(stp - 1, tra[LCM][i], (MOD * 10 + i) % 2520,
                 LIM && i == dig[stp]);
    }
    return LIM ? sum : res = sum;
  }
}
long long sol(long long x) {
  top = 0;
  while (x) {
    dig[++top] = x % 10;
    x /= 10;
  }
  return dfs(top, 1, 0, 1);
}
void runprog() {
  long long l, r;
  scanf("%lld%lld", &l, &r);
  printf("%lld\n", sol(r) - sol(l - 1));
}
int main() {
  memset(f, -1, sizeof f);
  pak.push_back(1);
  for (int i = 1; i <= 2520; ++i) {
    if (2520 % i == 0) {
      pak.push_back(i);
    }
  }
  for (int i = 0; i < pak.size(); ++i) {
    pos[pak[i]] = i;
  }
  for (int i = 0; i < pak.size(); ++i) {
    for (int j = 0; j < pak.size(); ++j) {
      tra[i][j] = pos[lcm(pak[i], pak[j])];
    }
  }
  int t;
  scanf("%d", &t);
  while (t--) {
    runprog();
  }
}