#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int, int>
int32_t mod = 1e9 + 7;

void solveCase()
{
    int a = 0, b = 0;
    cin >> a >> b;
    int mx = abs(a - b);
    if (mx == 0)
    {
        cout << "0 0\n";
        return;
    }
    int moves = (a % mx ? min(a % mx, mx - a % mx) : 0);
    cout << mx << ' ' << moves << '\n';
}

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(NULL);
    int t = 0;
    cin >> t;
    while (t--)
        solveCase();
}