E
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll p=998244353;
int t;
ll l,r;
inline ll cal(ll x){
return x-x/2-x/5+x/10;
}
inline ll f(ll x){
ll res=0;
for(ll i=0,p2=1;p2<=x;p2*=2,i++){
for(ll j=0,p5=1;p2*p5<=x;p5*=5,j++){
res=(res+(max(i,j)+1)*(cal(x/p2/p5)-1)%p)%p;
}
}
return res;
}
inline void solve(){
cout<<(f(r)-f(l-1)+p)%p<<'\n';
}
int main() {
cin>>t;
while(t--){
cin>>l>>r;
solve();
}
return 0;
}