#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll  long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define pi M_PI
#define sz(x) (ll)(x.size())
#define fab(i,a,b) for(ll i=a;i<b;i++)
#define fn(i,n) for(ll i=0;i<n;i++)
//#define min(a,b) min((a) ,((b))
#define max(a,b) max((a) ,(double)(b))
#define fix(t) fixed<<setprecision(t) 

using namespace std;
using namespace __gnu_pbds;
bool isPrime(ll n)
{
    if (n <= 1)	return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;
}

void solve(){
	ll a,b;
	cin>>a>>b;
	if(a<b) 	swap(a,b);
	if(a==b) cout<<"0 0\n";
	else if(b==0) cout<<a<<" 0\n";
	else
	{
		ll g=a-b;
		cout<<g<<" "<<min((b%g), (g-(b%g)))<<"\n";
	}
	
}

signed main(){
	fast;
	int test = 1,p=1;
	cin>>test;
	while(test--){
    solve();
  }
}