#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   int t;
   cin>>t;
   while(t--)
   {
       long long int a,b;
       cin>>a>>b;
       /*vector<long long int>a(n);
       for(int i=0;i<n;i++)
       {
           cin>>a[i];
       }*/
       if(a==b)
       {
           cout<<"0 0"<<endl;
           continue;
       }
       long long int m = min(a,b),diff=abs(a-b);
       long long int gd = 0;
       if(a==0||b==0)
       {
           gd=a+b;
       }
       else
       gd=__gcd(a,b);
       
       if(gd>=diff)
       {
           cout<<gd<<" 0"<<endl;
       }
       else
       {
           cout<<diff<<" "<<min(m,(diff-(a%diff)))<<endl;
       }
   }
   
   return 0;
}