#include<iostream>
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007

// void func(){

// }

void solution(){
  ll a,b; cin>>a>>b;
  ll val = abs(a-b);
  if(val==0){
    cout<<"0 0"<<endl;
    return;
  }
  ll count = min(val-(a%val),a%val);
  cout<<val<<" "<<count<<endl;
}

int main(){

  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int t;
  cin>>t;
  // func();
  while(t--){
    solution();
  }

  return 0;
}