#include <bits/stdc++.h>

#define cs(n) scanf("%d", &n)
#define lcs(n) scanf("%lld", &n)
#define F(i, j, k) for(int i = j; i <= k; ++i)

using namespace std;
using ll = long long;
const int MAXN = 1000004;
const int INF = 0x3f3f3f3f;

int main() {
    int T; cs(T);
	while(T--) {
		ll a; lcs(a);
		ll b; lcs(b);
		if(a == b) {
			puts("0 0"); continue;
		}
		ll d = abs(a - b);
		if(a > b) swap(a, b);
		printf("%lld %lld\n", d, min(a % d, d - a % d));
	}	
 	return 0;
}
