#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

void testcase () {
	ll a, b;
	cin >> a >> b;
	
	if (a < b) 
		swap (a, b);
	
	if (a == b) {
		puts ("0 0");
		return;
	}
	
	ll diff = a - b;
	cout << diff << ' ' << min (a % diff, diff - (a % diff)) << "\n";
	
	return;
}

int main () {
	int t = 1;
	cin >> t;
	
	while (t--) {
		testcase();
	}
	
	return 0;
}
