#include <bits/stdc++.h>

using namespace std;
const int N = 2e5 + 10;
typedef long long ll;
int T = 1, n;
ll a[N];

ll count(ll x) {
    ll base = 0, plus = 1, ans = 0, cnt = -1;
    while(x) {
        ll k = x % 10;
        if (k) {
            cnt++;
            ans += base + plus * (k - 1);
        }
        x /= 10;
        base = (base + 1) * 10;
        plus = plus * 10 + 1;
    }
    return ans + cnt;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin >> T;
    while(T--) {
        ll l, r;
        cin >> l >> r;
        cout << count(r) - count(l) << '\n';
    }
    return 0;
}
