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

#define read(x)    freopen(x, "r", stdin);
#define write(x)   freopen(x, "w", stdout);

#define ll long long
#define lli long long int
#define FOR(n)          for(int i=0; i<(int)(n); ++i)
#define mod 1073741824
#define MAX 100001
#define gcd(a, b)   __gcd(a, b)





int main()
{
    ll t;
    cin>>t;
    while(t--)
   {
    ll n,m,a,b,flag;


    cin>>a>>b;
    flag =abs(a-b);
    if(flag == 0)
    {

        cout<<"0 "<<"0"<<endl;

    }
    else
    {

         cout<<flag<<" "<<min(a%flag,flag-(a%flag))<<endl;
    }




   }
   return 0;



}
