#!/usr/bin/env python
inputnum= int(input().strip())
output=""
for i in range(inputnum):
    lcm=0
    gcd=0
    inputlist = input().split()
    inputlist = [int(i) for i in inputlist]
    num1 = inputlist[0]
    num2 = inputlist[1]
    while num1 != num2:
        if num1>num2:
            num1-=num2
        else:
            num2-=num1
    gcd= num1
    lcd= (inputlist[0] * inputlist[1])/ gcd
    output+= "({} {})".format(gcd, int(lcd)) + " "

print(output.strip())
    

a0c01b5c50561bf44e5a3b86e49c34e076080092
<mask token>

<mask token>
for i in range(inputnum):
    lcm = 0
    gcd = 0
    inputlist = input().split()
    inputlist = [int(i) for i in inputlist]
    num1 = inputlist[0]
    num2 = inputlist[1]
    while num1 != num2:
        if num1 > num2:
            num1 -= num2
        else:
            num2 -= num1
    gcd = num1
    lcd = inputlist[0] * inputlist[1] / gcd
    output += '({} {})'.format(gcd, int(lcd)) + ' '
print(output.strip())

inputnum = int(input().strip())
output = ''
for i in range(inputnum):
    lcm = 0
    gcd = 0
    inputlist = input().split()
    inputlist = [int(i) for i in inputlist]
    num1 = inputlist[0]
    num2 = inputlist[1]
    while num1 != num2:
        if num1 > num2:
            num1 -= num2
        else:
            num2 -= num1
    gcd = num1
    lcd = inputlist[0] * inputlist[1] / gcd
    output += '({} {})'.format(gcd, int(lcd)) + ' '
print(output.strip())

#!/usr/bin/env python
inputnum= int(input().strip())
output=""
for i in range(inputnum):
    lcm=0
    gcd=0
    inputlist = input().split()
    inputlist = [int(i) for i in inputlist]
    num1 = inputlist[0]
    num2 = inputlist[1]
    while num1 != num2:
        if num1>num2:
            num1-=num2
        else:
            num2-=num1
    gcd= num1
    lcd= (inputlist[0] * inputlist[1])/ gcd
    output+= "({} {})".format(gcd, int(lcd)) + " "

print(output.strip())
    
