#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr) ,cout.tie(nullptr);
const int mod = 1000000007;
using namespace std;
void solve(){
  ll a,b;
  cin>>a>>b;
  if(a==b){
    cout<<0<<" "<<0<<endl;
    return ;
  }
  if(a>b)
    swap(a,b);
  ll gcd = abs(b-a);
  ll k = a%gcd;
  ll p= gcd-k;
  cout<<gcd<<" "<<min(k,p)<<endl;
}

int main(){
    fast
    ll t;
    cin>>t;
    while(t--){
        solve();
    }
	return 0;
}




                                                