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

#define int long long

void solve(){
	int a, b;
	cin >> a >> b;

	if (a == b) {
		cout << "0 0\n";
		return;
	}

	if (a < b) swap(a, b);

	if (!b) {
		cout << a << ' ' << 0 << '\n';
		return;
	}

	int d = a - b;

	int x = b % d;

	cout << d << ' ' << min(x, d - x) << '\n';

}

signed main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	#ifdef local
	freopen("inp.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	
	int test;
	cin >> test;

	while (test--)	
	solve();

}