#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1e9 + 7;
ll dp(ll a){
string s = to_string(a);
ll sol = 0;
ll tmp = 1;
for(int i = 0; i < s.size() - 1; i++){
tmp *= 10;
}
ll g = s[0] - '0' - 1;
// sol += (tmp * g * (g + 1) / 2);
for(int j = 1; j < (int)s.size(); j++){
ll tmp = 1;
ll ans = 0;
for(int i = 0; i < (int)s.size() - 1; i++)tmp *= 10;
for(int i = 0; i < j; i++){
tmp /= 10;
if(s[i] == '0'){
tmp *= ('9' - s[i] + 1);
continue;
}
tmp *= (s[i] - '0');
ans += tmp;
tmp /= (s[i] - '0');
tmp *= ('9' - s[i] + 1);
}
sol += ans;
}
return sol;
}
void solve(){
ll a, b;
cin >> a >> b;
ll g = dp(b);
ll h = dp(a);
string s = to_string(b);
ll tmp = 0;
for(auto x: s){
tmp += (x - '0');
}
cout << g << " " <<h << "\n";
cout << g - h + tmp << "\n";
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
for(int i = 1; i <= t; i++){
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbGwgbG9uZyBsb25nCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1PRCA9IDFlOSArIDc7CgpsbCBkcChsbCBhKXsKCXN0cmluZyBzID0gdG9fc3RyaW5nKGEpOwoJCglsbCBzb2wgPSAwOwoJbGwgdG1wID0gMTsKCWZvcihpbnQgaSA9IDA7IGkgPCBzLnNpemUoKSAtIDE7IGkrKyl7CgkJdG1wICo9IDEwOwoJfQoJbGwgZyA9IHNbMF0gLSAnMCcgLSAxOwoJLy8gc29sICs9ICh0bXAgKiBnICogKGcgKyAxKSAvIDIpOwoJZm9yKGludCBqID0gMTsgaiA8IChpbnQpcy5zaXplKCk7IGorKyl7CgkJbGwgdG1wID0gMTsKCQkKCQlsbCBhbnMgPSAwOwoJCWZvcihpbnQgaSA9ID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