#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){

	ios::sync_with_stdio(false);cout.tie(0);cin.tie(0);
	int te;
	cin>>te;
	while(te--){
		ll a,b;
		cin>>a>>b;
		if(a<b) swap(a,b);
		if(a==b){
			cout<<"0 0\n";
		}else{
			ll t=a-b;
			cout<<t<<' '<<min(b%t,t-b%t)<<'\n';
		}
	}


	return 0;
}

