#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef pair<ll, ll> pii;

const int N = 2e5 + 10, MOD = 1e9 + 7;
int n, m, t, ans, tmp, k1, k2, ans1, ans2;
int a[N], b[N];
string s;

void read_input() {
	cin >> n >> m;
	tmp = max(n, m) - min(n, m);
	cout << tmp << ' ';
	if (tmp == 0) {
		cout << 0 << '\n';
		return;
	}
	k1 = n % tmp;
	k2 = tmp - k1;
	cout << min(k1, k2) << '\n';
}

int32_t main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> t;
	while(t--) {
		read_input();
		
	}
	
	return 0;
}
