#include "bits/stdc++.h"
using namespace std;

#define all(v) v.begin(), v.end()
#define rep(i, a, n) for (auto i = a; i <= n; i++)
#define f(i, n) for (auto i = 0; i < n; i++)
#define frev(i, n) for (auto i = n; i >= 0; i--)
#define fr first
#define sc second
#define pb emplace_back
#define pf push_front
#define mp make_pair
#define deb(x) cout << #x << "=" << x << endl
#define ll long long
#define endl "\n"
#define mem(a, val) memset(a, val, sizeof(a))
#define pow(a, b) (ll)(pow(a, b) + 0.5)
const ll inf = LLONG_MAX;
const int mod = 1000000007;
const int maxn = 1000001;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll x = 0, f = 0, q = 1, j, y, i, n, m, k;
  cin >> q;
  while (q--) {
    cin >> n >> m;
    ll ans = m - n;
    for (int i = 0; i < 10; i++) {
      m /= 10;
      n /= 10;
      ans += m - n;
    }
    cout << ans;
    cout << endl;
  }
}