Two integers A and B are the inputs. Write a program to find GCD and LCM of A and B.

-----Input-----

The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer A and B. 

-----Output-----
Display the GCD and LCM of A and B separated by space respectively. The answer for each test case must be displayed in a new line.

-----Constraints-----
- 1 ≤ T ≤ 1000
- 1 ≤ A,B ≤ 1000000

-----Example-----
Input
3 
120 140
10213 312
10 30

Output

20 840
1 3186456
10 30

Difficulty: interview

Starter code:

Solutions:
# cook your dish here
def GCD(x, y):  
   while y: 
    x, y = y, x % y  
   return x 

def LCM(x, y):
   lcm = (x*y)//GCD(x,y)
   return lcm

t = int(input())
while t>0:
    x,y = list(map(int,input().split()))
    print(GCD(x,y),LCM(x,y))  
    t -=1


import math
tc = int(input())
for i in range(tc):
    x,y = list(map(int,input().split()))
    gcd = math.gcd(x,y)
    lcm = (x*y)//gcd
    print(gcd,lcm)


# cook your dish here
import math
def find():
    x,y = map(int,input().split())
    a = math.gcd(x,y)
    lcm = (x*y)//a
    print(a,lcm)
 

for i in range(int(input())):
    find()

# cook your dish here
import math
def find():
    x,y = list(map(int,input().split()))
    a = math.gcd(x,y)
    lcm = (x*y)//a
    print(a,lcm)
 

for i in range(int(input())):
    find()


# cook your dish here
import math
def find():
    x,y = map(int,input().split())
    a = math.gcd(x,y)
    lcm = (x*y)//a
    print(a,lcm)
 

for i in range(int(input())):
    find()

# cook your dish here
import math
T = int(input())
while(T>0):
    A,B = map(int,input().split())
    hcf = math.gcd(A,B)
    lcm = (A*B)//hcf
    print(hcf,lcm)
    T = T - 1

# cook your dish here
import math
t = int(input())
for i in range(0, t):
    (a, b) = map(int, input() .split())
    gcd = math.gcd(a,b)
    lcm = int((a*b)/gcd)
    print(gcd,lcm)

import math
for t in range(int(input())):
    a,b=map(int, input().split())
    x=math.gcd(a,b)
    y=(a*b)//x
    print(x,y)

# cook your dish here
import math
n=int(input())
for i in range(n):
    a,b=input().split()
    a=int(a)
    b=int(b)
    x=math.gcd(a,b)
    y=(a*b)//x
    print(x,y)
 
 
 
    # if n1>n2:
    #     large = n1 
    #     small = n2
    # else:
    #     large = n2
    #     small = n1
    # lt = large
    # st = small
    # while(st!=0):
    #     if small%st == 0 and large%st == 0:
    #         break
    #     else:
    #         st = st - 1


import math
n=int(input())
for i in range(n):
    a,b=input().split()
    a=int(a)
    b=int(b)
    x=math.gcd(a,b)
    y=(a*b)//x
    print(x,y)

def GCD(a,b):
    if(b==0):
     return a
    else:
     return (GCD(b,a%b))
n=int(input())
for i in range(n):
    a,b=input().split()
    a,b=int(a),int(b)
    c=GCD(a,b)
    d=(a*b)//c
    print(c,d)

t = int(input())

def gcd(a, b):
 
    while a != b:
     if a > b:
      a = a - b
     else:
      b = b - a
    return a

for _ in range(t):
    int_1,int_2 = list(map(int,input().split()))
 
    hcf = gcd(int_1,int_2)
 
    lcm = (int_2*int_1)/hcf
 
    print(int(hcf),int(lcm))
 


# cook your dish here
from sys import stdin, stdout


def gcd(A, B):
    if B == 0:
     return A
  
    else:
     return gcd(B, A%B)


for _ in range(int(stdin.readline())):
    A, B = list(map(int, stdin.readline().split()))
    g = gcd(A, B)
    l = A // g * B
    stdout.write(str(g)+" ")
    stdout.write(str(l)+"\n")


# cook your dish here
t=int(input())

for _ in range(t):
    a,b=map(int,input().split())
    dup1=a
    dup2=b
    while(b!=0):
     temp=b 
     b=a%b 
     a=temp
    gcd=int(a) 
    lcm=int ((dup1*dup2)/gcd)
    print(gcd, lcm)

import math
N=int(input())
for i in range(N):
    a,b=list(map(int,input().split()))
    c=math.gcd(a,b)
    lcm=(a*b)//c
    print(c ,lcm)
 


import math
t=int(input())
for i in range(t):
    a,b=map(int,input().split(" "))
    c=math.gcd(a,b)
    l=(a*b)//c
    print(c," ",l)