#include <bits/stdc++.h>

using namespace std;
using ll = long long;



void solve() {
  ll a, b;
  cin>>a>>b;
  
  if(a == b){
      cout<<0<<" "<<0<<"\n";
  }
  else {
      ll k = max(a, b)-min(a, b);
      cout<<k<<" "<<min(k-(b%k), b%k)<<"\n";
  }
  

}

int main() {

  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}