#The solution in Python 3 is as follows:
from fractions import gcd
t=int(input())
i=0
while i<t:
A, B = map(int, input().split()) #input a and b
g = gcd(A, B) #finding GCD
print (B//g, A//g)
i+=1
#Visit this link for detailed understanding.
#Keep visiting for more solutions of SPOJ problems in Python 3.Thank you!!!
from fractions import gcd
t=int(input())
i=0
while i<t:
A, B = map(int, input().split()) #input a and b
g = gcd(A, B) #finding GCD
print (B//g, A//g)
i+=1
#Visit this link for detailed understanding.
#Keep visiting for more solutions of SPOJ problems in Python 3.Thank you!!!