#include<bits/stdc++.h>
using namespace std;

const int N=100200;
typedef long long ll;

int main(){
    ll t;
    ll a, b, k, mi;
    cin>>t;
    while(t--){
        cin>>a>>b;
        if(b>a)swap(a,b);
        if(a==b)cout<<"0 0"<<endl;
        else{
            k=a-b;
            mi=min(a%k,k-a%k);
            cout<<k<<" "<<mi<<endl;
        }
    }
    return 0;
}