https://www.acmicpc.net/problem/2702
n=int(input())
for i in range(n):
a,b=map(int,input().split())
min=0
max=0
j=1
while 1:
if a%j==0 and b%j==0:
max=j
if j%a==0 and j%b==0:
min=j
break
j+=1
print("%d %d" % (min,max))