def exgcd(a, b, x, y):
if b == 0:
return 1, 0
x1, y1 = exgcd(b, a%b, y, x)
x, y = y1, x1 - a//b * y1
return x, y
n = int(input())
for df in range(n):
s = input().split()
a, b = map(int, s)
x, y = exgcd(a, b, 123, 456)
print(x, y)