#include <iostream>
#include<string>
#include<algorithm>
#include<climits>
#include<cmath>
#include<vector>
#include<map>

using namespace std;
#define ll long long
// void pg()
// {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
//    }

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

   ll a,b;
   cin>>a>>b;

   if(a==b){
       cout<<0<<" "<<0<<endl;
       continue;
   }
  ll c=abs(a-b);
  
 ll d=c-(a%c);
 d=min(d,c-d);
 if(a%c==0) d=0;
 cout<<c<<" "<<d<<endl;






}
return 0;  
      
}