#include<bits/stdc++.h>
using namespace std; 
#define ll long long 
ll const MAX_N=1e7+5; 
int main(){
	ll t; cin>>t; 
	while(t--){
	ll a, b; cin>>a>>b; 
	    ll ans=0; 
	    ll a1=max(a,b); ll a2=min(a,b);
	    if(a1*2==b){
	    	cout<<a1<<" "<<0<<endl; 
		}
	    else if(a1==a2){
	    	cout<<0<<" "<<0<<endl; 
		}
		else{
			ll ans1=0; ll ans2=0;
		ans1=a1-a2; 
		     ll k1=0;ll k2=0; 
		     k1=a2%ans1; 
		     k2=a2/ans1; 
		     k1=min(k1,(k2+1)*ans1-a2);
		     cout<<ans1<<" "<<k1<<endl;
		//	else cout<<ans1<<" "<<a2<<endl; 
		}
	}
	
}