#include<bits/stdc++.h>
using namespace std;
#define int int64_t

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

signed main(){

	ios_base::sync_with_stdio(false);cin.tie(NULL);

	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
	
}