#include<bits/stdc++.h>
using namespace std;
#define int long long 
int t, a, b;
signed main()
{
	for(cin >> t; t--; )
	{
		cin >> a >> b;
		if(a == b)
		{
			cout << "0 0\n";
			continue;
		}
		if(a < b)
			swap(a, b);
		int ans = a - b;
		cout << ans << " " << min(ans-b%ans, b%ans) << "\n";
	}
}