#include <bits/stdc++.h>
using namespace std;
void solve(){
    long long a,b;
    cin>>a>>b;
    if(a==b)
        cout<<0<<" "<<0<<endl;
    else{
        cout<< abs(a-b)<<" "<<min(a%abs(a-b), abs(a-b)-a%abs(a-b))<<endl;
    }
}
int main()
{
    int t = 1;
    cin >> t;
    while (t--){
        solve();
     }
    return 0;
}