#include <bits/stdc++.h>
#define ll long long int
#define st string
#define pb(x) push_back(x)
#define sz size()
using namespace std;
const ll maxn=1e3*2+1,maxv=1e6,mod=1e9;
ll a1[maxn];
ll dp[maxn];
int main()
{   std::ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0);
    ll n,a,b;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a>>b;
        ll c=abs(a-b);
        if(c==0)
            cout<<0<<" "<<0<<endl;
        else
            cout<<c<<" "<<min((a%c),c-(a%c))<<endl;
    }
}
