#include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long
int main() {
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    { ll a,b,d;
      cin>>a>>b;
      if(a==b)
      {
        cout<<0<<" "<<0<<"\n";
      }
      else if(abs(a-b)==1)
      {
        cout<<1<<" "<<0<<"\n";
      }
      else
      { d=abs(a-b);
        ll prv=(a/d)*d;
        ll next=((a/d)+1)*d;
        ll ans=min((next-a),(a-prv));
        cout<<d<<" "<<ans<<"\n";
      }
    }
}