#include<bits/stdc++.h>
#define inf 100000000
#define int long long
#define ll long long
#define fr(a,b) for(int i = a; i < b; i++)
#define rep(i,a,b) for(int i = a; i < b; i++)
#define repn(i,a,b) for(int i = a-1; i >=0; i--)
#define prDouble(x) cout << fixed << setprecision(10) << x
#define endl "\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define read(x) int x; cin >> x
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pi pair < int,int >
using namespace std;
signed main()
{
    fast_io;
    int t;
    cin>>t;
    while(t--) 
    {
        int a,b;
        cin>>a>>b;
        int x=abs(a-b);
        if (x==0) cout<<0<<" "<<0<<endl;
        else cout<<abs(a-b)<<" "<<min((b%x),x-(b%x))<<endl;
    }  
}