#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  for (int h = 0; h < t; h++) {
    long long a, b;
    cin >> a >> b;
    if (a == b) {
      cout << "0 0" << endl;
    } else {
      if (a < b) {
        swap(a, b);
      }
      long long r = a - b;
      if (b % r > r - b % r) {
        cout << r << " " << r - b % r << endl;
      } else {
        cout << r << " " << b % r << endl;
      }
    }
  }
}
