import collections
import fractions

P =1000000007

N = int(input())
ABs = []
for _ in range(N):
  a,b = map(int, input().split)
  if b == 0:
    ABs.append([1,0])
  elif b > 0:
    c = fractions.gcd(a,b)
    ABs.append([a//c, b//c])
  else:
    c = fractions.gcd(abs(a),abs(b))
    ABs.append([-a//c, -b//c])

print(ABs)