#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int exgcd(int a,int b,int &x,int &y)
{
if(b == 0)
{
x = 1,y = 0;
return a;
}
int x1,y1,t;
t = exgcd(b,a % b,x1,y1);
x = y1;
y = x1 - a / b * y1;
return t;
}
int main()
{
int n;
cin >> n;
while(n --)
{
int a,b,x,y;
cin >> a >> b;
exgcd(a,b,x,y);
cout << x << ' ' << y << endl;
}
return 0;
}