Problem: Let's call some positive integer classy if its decimal representation contains no more than 3 non-zero digits. For example, numbers 4, 200000, 10203 are classy and numbers 4231, 102306, 7277420000 are not.

You are given a segment [L; R]. Count the number of classy integers x such that L ≤ x ≤ R.

Each testcase contains several segments, for each of them you are required to solve the problem separately.

Input

The first line contains a single integer T (1 ≤ T ≤ 10^4) — the number of segments in a testcase.

Each of the next T lines contains two integers L_i and R_i (1 ≤ L_i ≤ R_i ≤ 10^{18}).

Output

Print T lines — the i-th line should contain the number of classy integers on a segment [L_i; R_i].

Example

Input

4
1 1000
1024 1024
65536 65536
999999 1000001


Output

1000
1
0
2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast", "inline")
using namespace std;
bool Finish_read;
template <class T>
inline void read(T &x) {
  Finish_read = 0;
  x = 0;
  int f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    if (ch == EOF) return;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x *= f;
  Finish_read = 1;
}
template <class T>
inline void print(T x) {
  if (x / 10 != 0) print(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
inline void writeln(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
  putchar('\n');
}
template <class T>
inline void write(T x) {
  if (x < 0) putchar('-');
  x = abs(x);
  print(x);
}
int T;
long long l, r, f[19][4];
vector<int> dig;
inline long long dfs(int pos, int cnt, bool up) {
  if (cnt > 3) return 0;
  if (pos == -1) return cnt <= 3;
  if (~f[pos][cnt] && !up) return f[pos][cnt];
  long long res = 0;
  int ux = up ? dig[pos] : 9;
  for (int u = 0; u <= ux; ++u)
    res += dfs(pos - 1, cnt + (u > 0), up && u == ux);
  if (!up) f[pos][cnt] = res;
  return res;
}
inline long long calc(long long x) {
  dig.clear();
  while (x) dig.push_back(x % 10), x /= 10;
  memset(f, -1, sizeof f);
  return dfs(dig.size() - 1, 0, 1);
}
int main() {
  read(T);
  while (T--) read(l), read(r), printf("%lld\n", calc(r) - calc(l - 1));
}