#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
/*int gcd(ll n1,ll n2)
{
   return _gcd(n1,n2);
}
*/int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
 #endif 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t;
    cin>>t;
    while(t--)
    {
      ll a,b,c,d;
      cin>>a>>b;
      d=abs(a-b);
      if(d==0)
      {
         cout<<"0 0"<<endl;
      }
      else
      {
         c=min(a%d , d-(a%d));
         cout<<d<<" "<<c<<endl;
      }     
    }

}
