#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FAST1 ios_base::sync_with_stdio(false);
#define FAST2 cin.tie(NULL);

void solve()
{
ll a,b;
cin>>a>>b;
ll ans=abs(a-b);
if(ans==0)
{
    cout<<"0 0";
}
else
cout<<ans<<" "<<min(a%ans,ans-a%ans);
} 
int main(){
    FAST1;
    FAST2;
    int t;
    cin>>t;

    while(t--)
    {
        solve();
        cout<<endl;
    }

}

