
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pi 3.1415926535
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define zer(x) memset(x,0,sizeof x)
#define pii pair<ll,ll>


//PLEASE DON'T HACK I AM POOR :(
using namespace std;

int main()
{
	fastio
	ll t;
	cin>>t;
	vector<vector<ll> >dp(11,vector<ll>(10,0));
	{
		ll i,j,sum=0;
		for(i=0;i<=10;i++)
		{
			for(j=0;j<=9;j++)
			{
				if(j==0)
				{
				dp[i][j]=0;	
				}
				else
				{
					if(i==0)dp[i][j]=j;
					else
					{
						if(j==1)
						{
							dp[i][j]=sum+i+1;
						}
						else dp[i][j]=dp[i][j-1]+dp[i][1];
					}
				}
				
				if(j==9)sum+=dp[i][j];
//				cout<<dp[i][j]<<" ";
			}
//			cout<<"\n";
		}
	}
	while(t--)
	{
		ll i,j,k,l,m,n;
		ll a,b;
		cin>>a>>b;
		
		ll req=a;
		vector<ll>temp;
		while(req!=0)
		{
			temp.pb(req%10);
			req/=10;
		}
		ll ans1=0,ans2=0;
		for(i=0;i<temp.size();i++)ans1+=dp[i][temp[i]];
		
		temp.clear();
		req=b;
		while(req!=0)
		{
			temp.pb(req%10);
			req/=10;
		}
		
		for(i=0;i<temp.size();i++)ans2+=dp[i][temp[i]];
		cout<<abs(ans1-ans2)<<"\n";
//		cout<<m<<" "<<s1<<" "<<s2<<"  "<<" OPOP\n";
	}	
	return 0;
	
}
 
