#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i > (b); --i)
#define ALL(x) x.begin(), x.end()
#define F first
#define S second
#define PB push_back
#define MP make_pair

using namespace std;
using ll = long long;
using ld = long double;

typedef vector<int> vi;
typedef pair<int, int> pi;

void fast_io() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

/* ---------- Code here ---------- */

void solve() {
    ll a, b; cin >> a >> b;

    if (a == b) {
        cout << "0 0\n";
        return;
    }

    ll x = max(a, b), y = min(a, b);
    if (a == 0 || b == 0) {
        cout << x << " 0\n";
        return;
    }

    ll z = x - y;
    ll q = x % z, w = z - q;

    cout << z << " " << min(q, w) << "\n";
}

/* ---------- Main here ---------- */

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

    int T;
    cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}