#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		long long a,b,c,d,ans;
		scanf("%lld%lld",&a,&b);
		if(a==b) printf("0 0\n");
		else
		{
			c=abs(a-b);
			d=a%c;
			if(d<=c-d) ans=d;
			else ans=c-d;
			printf("%lld %lld\n",c,ans);
		}
	}
	return 0;
}
