#include<bits/stdc++.h>
#define ll long long
#define all( x ) x.begin() , x.end()

using namespace std ;

void solve()
{
    // If there is only one test case make t = 1
    ll a , b ;
    cin >> a >> b ;

    ll req = abs( a - b ) ;
    ll moves = 1e18 ;
    if( req )
    {
        ll x = min( a , b ) % req ;
        if( req - x > 0 )
            moves = x ;

        moves = min( moves , req - x ) ;
    }
    else
        moves = 0 ;

    cout << req << " " << moves << endl ;
}

int main()
{
    ios_base :: sync_with_stdio( false ) ;
    cin.tie( NULL ) ;

    int t ;
    cin >> t ;

    while( t-- )
        solve() ;
}

