#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x = 0;
  vector<long long> v;
  set<long long> tree;
  set<long long> tree_2;
  set<long long> tree_3;
  v.reserve(15000);
  long long k = 1;
  while (x <= 999999999999999999LL) {
    x = k;
    for (long long i = 0; i < 9; ++i) {
      tree.insert(x);
      x += k;
    }
    k *= (long long)10;
    x = k;
  }
  long long p = 1, dig, lim = 2, divi = 1, modulo = 1;
  int tam = v.size();
  set<long long>::iterator gg;
  set<long long>::iterator fin;
  long long ele;
  for (gg = tree.begin(); gg != tree.end(); gg++) {
    ele = *gg;
    divi = 1;
    modulo = 10;
    tree_2.insert(ele);
    while (modulo <= ele) {
      dig = ele % modulo;
      dig = dig / divi;
      if (dig == 0) {
        for (long long d2 = 1; d2 <= 9; ++d2) tree_2.insert(ele + d2 * divi);
      }
      modulo *= 10;
      divi *= 10;
    }
  }
  for (gg = tree_2.begin(); gg != tree_2.end(); gg++) {
    ele = *gg;
    divi = 1;
    modulo = 10;
    tree_3.insert(ele);
    while (modulo <= ele) {
      dig = ele % modulo;
      dig = dig / divi;
      if (dig == 0) {
        for (long long d2 = 1; d2 <= 9; ++d2) tree_3.insert(ele + d2 * divi);
      }
      modulo *= 10;
      divi *= 10;
    }
  }
  int iii = 0;
  for (gg = tree_3.begin(); gg != tree_3.end(); gg++) v.push_back(*gg);
  v.push_back(999999999999999999LL + 1);
  long long a, b;
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld %lld", &a, &b);
    a = (long long)(lower_bound(v.begin(), v.end(), a) - v.begin());
    b = (long long)(upper_bound(v.begin(), v.end(), b) - v.begin());
    printf("%lld\n", b - a);
  }
  return 0;
}

### Prompt

Construct a cpp code solution to the problem outlined:

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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x = 0;
  vector<long long> v;
  set<long long> tree;
  set<long long> tree_2;
  set<long long> tree_3;
  v.reserve(15000);
  long long k = 1;
  while (x <= 999999999999999999LL) {
    x = k;
    for (long long i = 0; i < 9; ++i) {
      tree.insert(x);
      x += k;
    }
    k *= (long long)10;
    x = k;
  }
  long long p = 1, dig, lim = 2, divi = 1, modulo = 1;
  int tam = v.size();
  set<long long>::iterator gg;
  set<long long>::iterator fin;
  long long ele;
  for (gg = tree.begin(); gg != tree.end(); gg++) {
    ele = *gg;
    divi = 1;
    modulo = 10;
    tree_2.insert(ele);
    while (modulo <= ele) {
      dig = ele % modulo;
      dig = dig / divi;
      if (dig == 0) {
        for (long long d2 = 1; d2 <= 9; ++d2) tree_2.insert(ele + d2 * divi);
      }
      modulo *= 10;
      divi *= 10;
    }
  }
  for (gg = tree_2.begin(); gg != tree_2.end(); gg++) {
    ele = *gg;
    divi = 1;
    modulo = 10;
    tree_3.insert(ele);
    while (modulo <= ele) {
      dig = ele % modulo;
      dig = dig / divi;
      if (dig == 0) {
        for (long long d2 = 1; d2 <= 9; ++d2) tree_3.insert(ele + d2 * divi);
      }
      modulo *= 10;
      divi *= 10;
    }
  }
  int iii = 0;
  for (gg = tree_3.begin(); gg != tree_3.end(); gg++) v.push_back(*gg);
  v.push_back(999999999999999999LL + 1);
  long long a, b;
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld %lld", &a, &b);
    a = (long long)(lower_bound(v.begin(), v.end(), a) - v.begin());
    b = (long long)(upper_bound(v.begin(), v.end(), b) - v.begin());
    printf("%lld\n", b - a);
  }
  return 0;
}

```