#include <bits/stdc++.h>
using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(nullptr);
#define ll long long
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

const int oo = 1e9;
const ll INF = 1e18;

ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }

    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);

    x = y1;
    y = x1 - y1 * (a / b);

    return d;
}

bool find_any_solution(ll a, ll b, ll c, ll& x0, ll& y0, ll& g) {
    g = gcd(abs(a), abs(b), x0, y0);

    if (c % g)
        return false;

    x0 *= c / g;
    y0 *= c / g;

    if (a < 0)
        x0 = -x0;

    if (b < 0)
        y0 = -y0;

    return true;
}

void solve() {
    ll n, k;
    cin >> n >> k;

    ll a = n / k;
    ll b = (n + k - 1) / k;
    ll x, y, g;
    find_any_solution(a, b, n, x, y, g);
    cout << x << " " << y << endl;
}

int main() {
    fast

    int t = 1;
    cin >> t;

    while (t--)
        solve();

    return 0;
}
