#include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
  int a,b;
  cin>>a>>b;
  if(a==b){
    cout<<0<<' '<<0<<'\n';
    return;
  }
  if(b<a)swap(a,b);
  set<int>facts;
  int diff=b-a;
  int ans=diff;
  int moves=b/diff;
  if(b%ans==0){
    cout<<ans<<" "<<0<<'\n';
    return;
  }else{
    cout<<ans<<" "<<min(b%diff,llabs(b-diff*(moves+1)))<<'\n';
  }
} 
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 int tt;
 cin>>tt;
 while(tt--){
     solve();
 }
return 0;
}