#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int tt; 
ll mod(ll x,ll y)
{
	ll res=x%y;
	if(res<0)res+=y;
	return res;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>tt;
	while(tt--)
	{
		ll a,b;
		cin>>a>>b;
		if(a<b)swap(a,b);
		ll x=a-b;
		if(x==0)cout<<0<<' '<<0<<endl;
		else cout<<x<<' '<<min(min(mod(a,x),mod(x-a,x)),min(mod(b,x),mod(x-b,x)))<<endl;
	}
//	cout<<mod(-2,3)<<' '<<(-2)%3;
	return 0;
}
