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

#define st first
#define nd second
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;

const ll MOD = 1e9 + 7;
const int N = 2e5 + 5;

int n, t;

ll gcd(ll a, ll b){
	if(a % b) return gcd(b, a % b);
	return b;
}

int main(){
	scanf("%d", &t);
	while(t--){
		ll a, b;
		scanf("%lld %lld", &a, &b);
		if(a == b) printf("0 0\n");
		else if(!a || !b) printf("%lld 0\n", max(a, b));
		else printf("%lld %lld\n", abs(a - b), min(a % abs(a - b), abs(a - b) - a % abs(a - b)));
	}
	return 0;
}
