#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T; cin >> T;
    while (T--) {
        ll a, b; cin >> a >> b;
        if (a == b) cout << "0 0\n";
        else {
            ll n = abs(a - b);
            cout << n << ' ';
            if (a % n == 0) cout << "0\n";
            else cout << min(a % n, n - a % n) << '\n';
        }
    }

    return 0;
}
