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

int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        long long a,b;
        cin>>a>>b;
      if(a==b)
        cout<<0<<" "<<0<<"\n";
      else
      {
        long long g = abs(a-b);
       long long d = min(a%g,g-a%g);
       cout<<g<<" "<<d<<"\n";
      }
    }
    return 0;
}
