#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main()
{

    int t;
    cin>>t;
    while(t--)
    {
        int a,b;
        cin>>a>>b;
        if(a==b)
        {
            cout<<"0 0"<<endl;
        }
        else
        {
            if(a<b) swap(a,b);
            int g=a-b;
            cout<<g<<" ";
            /*if(a%g==0)
                cout<<0<<endl;
            else*/
            {
                //cout<<(a/g+1)*g-a<<endl;
                cout<<min(a-a/g*g,(a/g+1)*g-a)<<endl;
            }
        }
    }
    return 0;
}