#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int main()
{
	


	int test;
	cin>>test;
   	while(test--)
	{
		
		long long int l,r;
		cin>>l>>r;
		long long int val = 1;
		long long int ans = 0;
		long long int cnt = 1;
		long long int diff = r-l;
		while(val <= r)
		{
		    long long int x = r/val - l/val;
		    ans+= x;
		    val*=10;
		    
		}
		cout << ans <<endl;
	
		
		
	}
}