#include <iostream>
#include<math.h>
using namespace std;
int main()
{

   long long int t,x,y;
    cin>>t;
    for(int i=0;i<t;++i)
    {
        cin>>x>>y;
        if(x==y)
            cout<<0<<" "<<0<<endl;
        else if(abs(x-y)==1)
            cout<<1<<" "<<0<<endl;
        else
        {

            if(x<y)
                swap(x,y);
            long long int dif=x-y;
            long long int index1,index2;
            index1=y%dif;
            index2=dif-(y%dif);
            if(index1<index2)
                cout<<dif<<" "<<index1<<endl;
            else
                cout<<dif<<" "<<index2<<endl;
        }
    }
    return 0;
}
