#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const string str="12233344445555566666677777778888888899999999910101010101010101010";
string s;
ll t,l,r,h;
signed main(){
cin>>t;
for(int i=1;i<=15400;i++)
s+=str;
while(t--){
cin>>l>>r;
for(int i=l-1;i<r;i++)
h+=s[i]-'0';
cout<<h<<endl;
h=0;
}
return 0;
}
悬关!