#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  long long a, b;
  while (t--) {
    cin >> a >> b;
    long long EMax = 0, SMin = 0;
    if (a == b)
      cout << "0 0" << endl;
    else {
      EMax = abs(a - b);
      SMin = min(a % EMax, EMax - a % EMax);
      cout << EMax << " " << SMin << endl;
    }
  }
  return 0;
}
