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>
using namespace std;
const int N = 20005;
const long long inf = 0x3f3f3f3fll;
const long long mod = 998244353ll;
int n, m;
long long po[20];
long long q[N];
long long s[N];
long long l[N], r[N];
int len;
void dfs(long long num, int step, int cnt) {
  if (step == 19) {
    int k = lower_bound(q + 1, q + n * 2 + 1, num) - q;
    s[k]++;
    return;
  }
  if (cnt < 3) {
    for (int i = 1; i <= 9; i++) {
      long long tmp = num + i * po[step];
      dfs(tmp, step + 1, cnt + 1);
    }
  }
  dfs(num, step + 1, cnt);
}
int main() {
  ios::sync_with_stdio(0);
  int i, j;
  cin >> n;
  po[0] = 1;
  for (i = 1; i < 20; i++) po[i] = po[i - 1] * 10ll;
  for (i = 1; i <= n; i++) {
    cin >> l[i] >> r[i];
    q[++len] = l[i] - 1;
    q[++len] = r[i];
  }
  sort(q + 1, q + 2 * n + 1);
  dfs(0, 0, 0);
  for (i = 1; i <= 2 * n; i++) s[i] += s[i - 1];
  for (i = 1; i <= n; i++) {
    int pos1 = lower_bound(q + 1, q + 2 * n + 1, l[i] - 1) - q;
    int pos2 = lower_bound(q + 1, q + 2 * n + 1, r[i]) - q;
    cout << s[pos2] - s[pos1] << endl;
  }
  return 0;
}