#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    #ifndef ONLINE_JUDGE
    //input from input.txt
        freopen("input.txt", "r", stdin);
    //output on output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ll tc;
    cin>>tc;
    for(int i=0;i<tc;i++)
    {
        ll a,b;
        cin>>a>>b;
        ll temp=abs(b-a);
        if(a==b)
        {
            cout<<0<<" "<<0<<endl;
            continue;
        }
        else
        {
            ll sel=max(a,b);
        ll low=sel/temp;
        ll high=((low+1)*temp)-sel;
        cout<<temp<<" "<<min(sel%temp,high)<<endl;
    }
    }
    return 0;
}