#include<cstdio>
using namespace std;
typedef long long ll;
ll exgcd(ll a,ll b,ll &x,ll &y)
{
if(!b)
{
x=1,y=0;
return a;
}
ll ret=exgcd(b,a%b,y,x);
y-=a/b*x;
return ret;
}
int main()
{
ll a,b,x,y;
int n;
scanf("%d",&n);
while(n--)
{
scanf("%lld%lld",&a,&b);
ll d=exgcd(a,b,x,y);
printf("%lld %lld\n",x,y);
}
return 0;
}