#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <optional>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using big = long long;

big f(int x) {
  auto s = to_string(x);
  big ans = 0;
  auto s2 = s[0] + string(s.size() - 1, '0');
  int y = stoi(s2);
  while (y) {
    ans += y;
    y /= 10;
  }
  if (s.size() > 1) {
    ans += f(stoi(s.substr(1)));
  }
  return ans;
}

int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  int cas;
  cin >> cas;
  while (cas--) {
    int l, r;
    cin >> l >> r;
    cout << (f(r) - f(l)) << "\n";
  }
}
