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

int main()
{
    ll t;
    cin>>t;

    while(t--)
    {
       ll a,b;
       cin>>a>>b;

       if(a==b)
        cout<<0<<" "<<0<<endl;
       else
       {
           ll gcd = abs(b-a);
           ll minn = min(a%gcd,gcd-a%gcd);
           cout<<gcd<<" "<<minn<<endl;
       }

    }

    return 0;
}
