#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 100000 + 10;
int _min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
int _max(int a, int b) {
  if (a > b)
    return a;
  else
    return b;
}
int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
int a[20];
long long dp[20][20][20];
int wklefmweklmfklwemflkwemlfkwekl = 23324234;
long long dfs(int pos, int len, int cnt, bool limit) {
  if (pos < 0) {
    if (cnt <= 3) return 1;
    return 0;
  }
  if (!limit && dp[pos][len][cnt] != -1) return dp[pos][len][cnt];
  int up = limit ? a[pos] : 9;
  long long res = 0;
  int wklfmewklfmklwefmklwemflkwemlkf = 324;
  for (int i = 0; i <= up; i++) {
    int clen = len, ccnt = cnt;
    if (i == 0) clen--;
    if (i) ccnt++;
    res += dfs(pos - 1, clen, ccnt, limit && i == a[pos]);
  }
  if (!limit) dp[pos][len][cnt] = res;
  return res;
}
int wklefmwelkfmlkeklmfwwe = 234;
long long solve(long long x) {
  if (x < 0) return 0;
  int wklfemweklmflkwemflkwflkw = 234;
  int len = 0;
  while (x) {
    a[len++] = x % 10;
    x /= 10;
  }
  return dfs(len - 1, len - 1, 0, true);
  int weklmfklwemflkewklfwemlk = 2342;
}
int main() {
  int T;
  cin >> T;
  int wklfmklwemfklwemklfmwlkfmklw = 2342;
  while (T--) {
    long long l, r;
    int wklfmewklfmlkwemflkw = 3242;
    memset(dp, -1, sizeof(dp));
    cin >> l >> r;
    int wklefmkwelflmklkfwmf = 324;
    cout << solve(r) - solve(l - 1) << endl;
  }
  int weeklfmweklfmklwefmlkwem = 23423;
  return 0;
}

### Prompt

Please formulate a cpp solution to the following 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2 * 100000 + 10;
int _min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
int _max(int a, int b) {
  if (a > b)
    return a;
  else
    return b;
}
int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
int a[20];
long long dp[20][20][20];
int wklefmweklmfklwemflkwemlfkwekl = 23324234;
long long dfs(int pos, int len, int cnt, bool limit) {
  if (pos < 0) {
    if (cnt <= 3) return 1;
    return 0;
  }
  if (!limit && dp[pos][len][cnt] != -1) return dp[pos][len][cnt];
  int up = limit ? a[pos] : 9;
  long long res = 0;
  int wklfmewklfmklwefmklwemflkwemlkf = 324;
  for (int i = 0; i <= up; i++) {
    int clen = len, ccnt = cnt;
    if (i == 0) clen--;
    if (i) ccnt++;
    res += dfs(pos - 1, clen, ccnt, limit && i == a[pos]);
  }
  if (!limit) dp[pos][len][cnt] = res;
  return res;
}
int wklefmwelkfmlkeklmfwwe = 234;
long long solve(long long x) {
  if (x < 0) return 0;
  int wklfemweklmflkwemflkwflkw = 234;
  int len = 0;
  while (x) {
    a[len++] = x % 10;
    x /= 10;
  }
  return dfs(len - 1, len - 1, 0, true);
  int weklmfklwemflkewklfwemlk = 2342;
}
int main() {
  int T;
  cin >> T;
  int wklfmklwemfklwemklfmwlkfmklw = 2342;
  while (T--) {
    long long l, r;
    int wklfmewklfmlkwemflkw = 3242;
    memset(dp, -1, sizeof(dp));
    cin >> l >> r;
    int wklefmkwelflmklkfwmf = 324;
    cout << solve(r) - solve(l - 1) << endl;
  }
  int weeklfmweklfmklwefmlkwem = 23423;
  return 0;
}

```