Title: GCD and LCM

Write a program to calculate the greatest common divisor (GCD) and the least common multiple (LCM) of given numbers a and b.

Input:
Several data sets, each containing two numbers a and b separated by a single space in a line. The input ends with EOF.

Constraints:
- 0 < a, b ≤ 2,000,000,000
- LCM(a, b) ≤ 2,000,000,000
- The number of data sets ≤ 50

Output:
For each data set, print GCD and LCM separated by a single space in a line.

Sample Input:
8 6
50000000 30000000

Output for the Sample Input:
2 24
10000000 150000000

# Buggy version:
while True:
    try:
        spam=map(int, input().split(' '))
        spam = [i for i in spam]
        spam.sort()
        cola = spam[0] * spam[1]
        while True:
            if spam[0] == 0:
                print(spam[1])
                print(int(cola/spam[1]))
                break
            pre = spam[0]
            spam[0] = spam[1] % spam[0]
            spam[1] = pre
    except:
        break

# Fixed version:
while True:
    try:
        spam=map(int, input().split(' '))
        spam = [i for i in spam]
        spam.sort()
        cola = spam[0] * spam[1]
        while True:
            if spam[0] == 0:
                print('{} {}'.format(spam[1],int(cola/spam[1])))
                break
            pre = spam[0]
            spam[0] = spam[1] % spam[0]
            spam[1] = pre
    except:
        break

# Buggy version:
def gcd(a,b):
 if b==0:
  return a
 return gcd(b,a%b)

while True:
 try:
  a,b=[int(i) for i in input().split()]
 except EOFError:
  break
  

# Fixed version:
def gcd(a,b):
 if b==0:
  return a
 return gcd(b,a%b)

while True:
 try:
  a,b=[int(i) for i in input().split()]
  print(gcd(a,b),(a*b)//gcd(a,b))
 except EOFError:
  break

# Buggy version:
import sys

def gcd(m, n):
    if n != 0:
        return gcd(n, m % n)
    else:
        return m

for line in sys.stdin.readlines():
    m, n = map(int, line.split())
    g = gcd(m, n)
    l = m * n // g    # LCM
    print(g, ' ', l)

# Fixed version:
import sys

def gcd(m, n):
    if n != 0:
        return gcd(n, m % n)
    else:
        return m

for line in sys.stdin.readlines():
    m, n = map(int, line.split())
    g = gcd(m, n)
    l = m * n // g    # LCM
    print(g, l)

# Buggy version:
def GcdLCM():
    
    for line in sys.stdin:
        x,y=map(int,line.split())
        if x==None:
            break
        
        gcd = Gcd(x,y)
        lcm = int(x*y/gcd)

        print("{} {}".format(gcd,lcm))
       
def Gcd(x,y):
    while x!=0:
        x,y=y%x,x
    return y
        
    
GcdLCM()

# Fixed version:
import sys
def GcdLCM():
    for line in sys.stdin:
        x,y=map(int,line.split())
        if x==None:
            break
        
        gcd = Gcd(x,y)
        lcm = int(x*y/gcd)

        print("{} {}".format(gcd,lcm))
       
def Gcd(x,y):
    while x!=0:
        x,y=y%x,x
    return y
        
    
GcdLCM()

# Buggy version:
def main():
	import sys

	for line in sys.stdin:
		a, b = map(int, line.split())
		c = a*b

		while a % b != 0:
			a, b = b, a%b

		print(b, c*b)

if __name__ == '__main__':
	main()

# Fixed version:
def main():
	import sys

	for line in sys.stdin:
		a, b = map(int, line.split())
		c = a*b

		while a % b != 0:
			a, b = b, a%b

		print(b, c//b)

if __name__ == '__main__':
	main()

# Buggy version:
# This program computes GCD and LCM
# -*- coding: utf-8
import sys


def gcd(a, b):
    while b:
	a, b = b, a % b
    return a


def lcm(a, b):
    for i in range(max([a, b]), a*b + 1):
        if(i % a == 0 and i % b == 0):
            return i
    return a*b


for i in sys.stdin:
    try:
        line = [int(k) for k in i.split(" ")]
        g = gcd(max(line), min(line))
        print(str(g) + " " + str(line[0]*line[1]/g))  # + str(lcm(line[0], line[1]))
    except:
        raise
        exit()

# Fixed version:
# This program computes GCD and LCM
# -*- coding: utf-8
import sys


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


for i in sys.stdin:
    try:
        line = [int(k) for k in i.split(" ")]
        g = gcd(min(line), max(line))
        print(str(g) + " " + str(line[0]*line[1]//g))
    except:
        exit()

# Buggy version:
import sys
  
for s in sys.stdin:
    g,r=m,n = map(int,s.split())
    while r!=0:
      g,r = r,g%r
    print(g,m//g*n)

# Fixed version:
import sys
  
for s in sys.stdin:
    m,n = map(int,s.split())
    g,r = m,n
    while r!=0:
      g,r = r,g%r
    print(g,m//g*n)

# Buggy version:
def gcd(a, b):
    if (a % b) == 0:
        return b
    return gcd(b, a%b)


while True:
    try:
        nums = list(map(int, input().split()))
        print(gcd(nums[0], nums[1]))

    except EOFError:
        break

# Fixed version:
def gcd(a, b):
    if (a % b) == 0:
        return b
    return gcd(b, a%b)

def lcd(a, b):
    return a * b // gcd(a, b)


while True:
    try:
        nums = list(map(int, input().split()))
        print(gcd(nums[0], nums[1]), lcd(nums[0], nums[1]))

    except EOFError:
        break

# Buggy version:
t = 0
while t == 0:	
	try:
		x,y=[int(i) for i in input().split()]
	except:
		break
	else:
		a = x * y
		if x < y:
			x,y =y,x
		while y > 0:
			r = x % y
			x = y
			y = r
	print(str(x) + " " + str(a / x))

# Fixed version:
t = 0
while t == 0:	
	try:
		x,y=[int(i) for i in input().split()]
	except:
		break
	else:
		a = x * y
		if x < y:
			x,y =y,x
		while y > 0:
			r = x % y
			x = y
			y = r
	print(str(x) + " " + str(int(a / x)))

# Buggy version:
from math import gcd
from sys import stdin

for line in stdin:
    a,b = [int(i) for i in line.split()]
    g = gcd(a,b)
    print(g,int(a*b/g)

# Fixed version:
from math import gcd
from sys import stdin

for line in stdin:
    a,b = [int(i) for i in line.split()]
    g = gcd(a,b)
    print(g,int(a*b/g))

# Buggy version:
def gcd(a,b):
    if a > b:
        x = a
        y = b
    else:
        x = b
        y = a
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

def lcm(a,b,gcd):
    return a*b/gcd

while 1:
    try:
        a,b = [int(x) for x in input().split()]
        gcd = gcd(a,b)
        lcm = lcm(a,b,gcd)
        print('{} {}'.format(gcd,lcm))
    except:
        break

# Fixed version:
def gcd(a,b):
    if a > b:
        x = a
        y = b
    else:
        x = b
        y = a
    while y > 0:
        r = x % y
        x = y
        y = r
    return x

def lcm(a,b,c):
    return int(a*b/c)

while 1:
    try:
        a,b = [int(x) for x in input().split()]
        res_gcd = gcd(a,b)
        res_lcm = lcm(a,b,res_gcd)
        print('{} {}'.format(res_gcd,res_lcm))
    except:
        break

# Buggy version:
import sys 
for e in sys.stdin:
    a, b = map(int, e.split())
    p = a * b
    while b:
        a, b = b, a%b
        pass
    print (a,p/a)


# Fixed version:
import sys 
for e in sys.stdin:
    a, b = map(int, e.split())
    p = a * b
    while b:
        a, b = b, a%b
        pass
    print (a,p//a)

# Buggy version:
import sys
def gcd(a,b):
    if a%b==0:
        return b
    return gcd(b,a%b)

r=[list(map(int,line.split())) for line in sys.stdin]
for i in r:
    o=gcd(i[0],i[i])
    p=i[0]*i[1]/o
    print(o,p)



# Fixed version:
import sys
def gcd(a,b):
    if a%b==0:
        return b
    return gcd(b,a%b)

r=[list(map(int,line.split())) for line in sys.stdin]
for i in r:
    o=gcd(i[0],i[1])
    p=i[0]*i[1]/o
    print(o,int(p))

# Buggy version:
# Vol0005.
import sys


def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def get_gcd(x, y):
    if x < y: return get_gcd(y, x)
    # x >= yのときはx % yを計算してyとx % yの話にする。
    # ここでx % yのところが0ならばyが求める答えとなる。
    if y == 0: return x
    return get_gcd(y, x % y)

def main():
    data = []
    lines = sys.stdin.readlines()
    for line in lines:
        data.append(line.split())

    N = len(data)
    for i in range(N):
        a = int(data[i][0]); b = int(data[i][1])
        gcd = get_gcd(a, b)
        lcm = (a // gcd) * b
        print('%d %d' % (a, b))

if __name__ == "__main__":
    main()


# Fixed version:
# Vol0005.
import sys


def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def get_gcd(x, y):
    if x < y: return get_gcd(y, x)
    # x >= yのときはx % yを計算してyとx % yの話にする。
    # ここでx % yのところが0ならばyが求める答えとなる。
    if y == 0: return x
    return get_gcd(y, x % y)

def main():
    data = []
    lines = sys.stdin.readlines()

    for line in lines:
        data.append(line.split())

    N = len(data)
    for i in range(N):
        a = int(data[i][0]); b = int(data[i][1])
        gcd = get_gcd(a, b)
        lcm = (a // gcd) * b
        print('%d %d' % (gcd, lcm))

if __name__ == "__main__":
    main()

# Buggy version:
from sys import stdin
import math

def GCD(a,b):
    if(a%b==0):
        return b
    else:
        c = a%b
        return GCD(b,c)

def LCM(a,b):
    gcd = GCD(a,b)
    return int(a*b/gcd)

for line in stdin:
    a,b = line.split(" ")
    a = int(a)
    b = int(b)
    gcd = GCD(a,b)
    lcm = LCM(a,b)

    print(str(gcd)+" "+str(lcm))
    print()



# Fixed version:
from sys import stdin
import math

def GCD(a,b):
    if(a%b==0):
        return b
    else:
        c = a%b
        return GCD(b,c)

def LCM(a,b):
    gcd = GCD(a,b)
    return int(a*b/gcd)

for line in stdin:
    a,b = line.split(" ")
    a = int(a)
    b = int(b)
    gcd = GCD(a,b)
    lcm = LCM(a,b)

    print(str(gcd)+" "+str(lcm))

# Buggy version:
def gcd(a, b):
    while b:
        a, b = b, a % b
        return a

while True:
    try:
        a, b = map(int, (input.split()))
    except:
        break
    g = gcd(a, b)
    print(g, a * b // g)

# Fixed version:
def gcd(a, b):
    while b: a, b = b, a % b
    return a

while True:
    try:
        line = input()
    except:
        break
    a, b = map(int, line.strip().split())
    g = gcd(a, b)
    print(g, a * b // g)

# Buggy version:
import math
while 1:
    try:
        a,b = map(int, input().split())
        print(math.gcd(a,b))
    except:
        break


# Fixed version:
import math
while 1:
    try:
        a,b,=map(int,input().split())
        print(math.gcd(a,b),a*b//math.gcd(a,b))
    except:
        break

# Buggy version:
# AOJ 0005 GCD and LCM
# Python3 2018.6.9 bal4u

def lcm(a, b):
	return a/gcd(a, b)*b

def gcd(a, b):
	while b != 0:
		r = a % b
		a = b
		b = r
	return a

while True:
    try:
        a = list(map(int, input().split()))
        print(gcd(a[0], a[1]), lcm(a[0], a[1]))
    except EOFError:
        break


# Fixed version:
# AOJ 0005 GCD and LCM
# Python3 2018.6.9 bal4u
 
def lcm(a, b):
    return a // gcd(a, b) * b
 
def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a
 
while True:
    try:
        a = list(map(int, input().split()))
        print(gcd(a[0], a[1]), lcm(a[0], a[1]))
    except EOFError:
        break

# Buggy version:

while True:
????????try:
????????????????(a, b) = map(int, input().split(" "))
????????????????(x, y) = (a, b)
????????????????while (x != 0):
????????????????????????(x, y) = (y%x, x)
????????????????print("%s %s" %(y, a*b//y))
????????except:
????????????????break

# Fixed version:
while(True):
    try:
        (a, b) = map(int, input().split(" "))
        (x, y) = (a, b)
        while (x != 0):
            (x, y) = (y%x, x)
        print("%s %s" %(y, a*b//y))
    except:
        break

# Buggy version:
def gcd(a, b):
    while b:
        a, b = b, a % b
        return a

while True:
    try:
        a, b = map(int, input().split())
        print(gcd(a, b), a * b // gcd(a, b))
    except:
        break

# Fixed version:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
while True:
    try:
        a,b = map(int,input().split())
        print (gcd(a,b),a *b // gcd(a,b))
    except:
        break

# Buggy version:
def gcd(a, b):
	if b == 0: return a
	else: return gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)

while True:
	try:
		a, b = map(int, input().split())
		print(gcd(a, b), lcm(a, b))
	except EOFError:
		break

# Fixed version:
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

def lcm(a,b):
    return (a*b)//gcd(a,b)

while True:
    try:
        a,b=map(int,input().split())
    except:
        break
    print(gcd(a,b),lcm(a,b))

# Buggy version:
import math

try:
while True:
  a,b=map(int,input().split())
  print(math.gcd(a,b),a*b// math.gcd(a, b))
 except:
   pass
 

# Fixed version:
import math

while True:
  try:
    a, b = map(int, input().split())
    print(math.gcd(a, b), a * b // math.gcd(a, b))
  except:
    break