#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define foru(i, a, b) for(ll i=a; i < (b) ; i++)
#define fore(i, a, b) for(ll i=a ; i <= (b); i++)
const ll mod = 1e9+7, N = 2e6+7, M = 2e6+7, INF = INT_MAX/10;

ll power(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;}
ll str_to_int(string s){stringstream asteya(s); ll x=0; asteya>>x; return x;}
string int_to_str(ll n){return to_string(n);}


void testcase(){
    ll a,b,ans,moves,sub;
    cin>>a>>b;

    if(a==0  and b==0)
    cout<<0<<" "<<0<<endl;
    else{
           ans = abs(a-b);
           if(ans == 0) sub=0;
           else
            sub = min(a,b)%ans;
        if(ans > 0 && ans !=1)
        moves = min(sub, (ans-(a%ans))%ans);
        else
        moves = 0;

        cout<<ans<<" "<<moves<<endl;
    }

 
}

int main(){
    fast;
    int t=1;
    cin >> t;

    while(t--){
    	testcase();
    }  
    return 0;
}
