#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
LL gcd(LL a,LL b){
    return b ? gcd(b,b%a) : a;
}
void solve(){
    LL x,y;
    cin>>x>>y;
    if(x<y)swap(x,y);
    if(x==y)cout<<"0 0"<<endl;
    else{
        LL t = x - y;
        LL l = 0,r = 1e18 / t+1;
        while(l<r){
            LL mid = (l+r)/2;
            if(t*mid > y)r=mid;
            else l=mid+1;
        }
        LL s = min(l*t-y,y-(l-1)*t);
        cout<<t<<" "<<s<<endl;
    }
}
int main(){
    int T;
    cin>>T;while(T--)solve();
}