https://codeforces.com/gym/580226/problem/M

#include<bits/stdc++.h>
#define lc p<<1
#define rc p<<1|1
#define INF 2e9
using namespace std;

#define endl '\n'
using ll = long long;
using pii = pair<ll, ll>;
const double PI = acos(-1);
const int N=1e4+10;

void solve(){
	ll a,b;cin>>a>>b;
	if(a==b) {
		cout<<0<<" "<<0<<endl;
		return;
	}
	if(a>b) swap(a,b);
	ll ans=b-a;
	ll t=b/ans*ans;
	cout<<ans<<" "<<min(b-t,t-a)<<endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	
	int T = 1;
	cin>>T;
	while (T--) {
		solve();
	}
	
	return 0;
}