#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        long long int a,b;
        cin>>a>>b;
        long long int diff = abs(a-b);
        long long int moves = 0;
        if(a==b) cout<<0<<" "<<0<<"\n";
        else{
                if(a>diff) moves = a%diff;
                else moves = b%diff;
                if(moves>diff/2) moves = diff-moves;
                if(a==0){
                    diff = b;
                    moves = 0;
                }
                else if(b==0){
                    diff = a;
                    moves = 0;
                }
                else if(a%b==0 && b>=diff){
                    diff = b;
                    moves = 0;
                }
                else if(b%a==0 && a>=diff){
                    diff = a;
                    moves = 0;
                }
                cout<<diff<<" "<<moves<<"\n";
        }
    }
    return 0;
}
