#include <iostream>
using namespace std;
int exgcd(int a,int b,int &x,int &y)
{
if(b==0)
{
x=1,y=0;
return a;
}
int d=exgcd(b,a%b,x,y);
//求当前问题a,b的的系数
int tx=x,ty=y;
x=ty;
y=tx-a/b*ty;
return d;
}
int main()
{
int n;
cin>>n;
while(n--)
{
int a,b;
cin>>a>>b;
int x,y;
exgcd(a,b,x,y);
cout<<x<<" "<<y<<endl;
}
// cout << "Hello world!" << endl;
return 0;
}