#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int main() {
  int t;
  cin >> t;
  while(t--){
    long long a,b;
    cin >> a >> b;
    if(a == b){
      cout << 0 << " " << 0 << endl;
    }
    else{
      long long exc = abs(a-b);
      long long num = min(a%exc, exc - a%exc);
      cout << exc << " " << num << endl;
    }   
  }
}

