Problem:
GCD and LCM Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b . Input Input consists of several data sets. Each data set contains a and b separated by a single space in a line. The input terminates 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

Solution (Python):
import sys
for e in sys.stdin:
 g,d=a,b=list(map(int,e.split()))
 while d:g,d=d,g%d
 print(g,a*b//g)

Solution (Python):
import sys
for e in sys.stdin:
 a,b=list(map(int,e.split()));p=a*b
 while b:a,b=b,a%b
 print(a,p//a)

Solution (Python):
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)

Solution (Python):
from sys import stdin
from math import gcd
for line in stdin:
    a, b = map(int, line.split())
    g = gcd(a, b)
    print(g, a // g * b)

Solution (Python):
while True:
    try:
        a, b = map(int, input().split(" "))
        if a < b:
            key = a
            a = b
            b = key
        A = a
        B = b
        while a % b != 0:
            key = a % b
            a = b
            b = key
        key = int(A * B / b)
        print(b, key)
    except:
        break

Solution (Python):
def gcd(a, b):
    while b:
        a, b = b, a % b

    return a


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


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

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

Solution (Python):
import sys


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



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

lines = sys.stdin.readlines()
for line in lines:
    a = list(map(int, line.split(" ")))
    print(gcd(a[0], a[1]), lcm(a[0], a[1]))

Solution (Python):
import math
  
while True:
  try:
    a,b = list(map(int,input().split()))
    x = math.gcd(a,b)
    y = a * b // x
    print(x,y)
  except EOFError:
    break

Solution (Python):
while True:
    try:
        r = sorted(list(map(int, input().split())))
        
        
        def euclidfunc(a, b):
            while b != 0:
                a, b = b, a % b
            return a
        
        
        def lcmfunc(a, b):
            return a * b // euclidfunc(a, b)
        
        
        print("{a} {b}".format(a=euclidfunc(r[1], r[0]), b=lcmfunc(r[1], r[0])))
    except EOFError:
        break

Solution (Python):
while 1:
    try:
        a = list(map(int, input().split()))
        b=list(a)
        a.sort()
        while a[1]%a[0] != 0:
            a[1] %= a[0]
            a.sort()
        print(a[0], int(b[0]*b[1]/a[0]))
    except:
        break

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

Solution (Python):
import sys
for i in sys.stdin:
    a, b = map(int, i.split())
    p, q = max(a, b), min(a, b)
    while True:
        if p % q == 0:
            break
        else:
            p, q = q, p % q
    print("{} {}".format(q, int(a * b / q)))

Solution (Python):
import sys
for i in sys.stdin:
    a, b = map(int, i.split())
    p, q = max(a, b), min(a, b)
    while p % q != 0:
        p, q = q, p % q
    print("{} {}".format(q, int(a * b / q)))

Solution (Python):
def F(x, y):
    if x % y == 0:
        return y
    return F(y, x % y)
while True:
    try:
        x, y = map(int,input().split())
        print('{0} {1}'.format(F(x, y), int(x * y / F(x, y))))
    except EOFError:
        break

Solution (Python):
def gcd(a,b):
	if a%b==0:
		return b
	else:
		r=a%b
		return gcd(b,r)

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


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

	except EOFError:
		break

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

Solution (Python):
import math

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

        gcd = math.gcd(a, b)
        lcm = a * b // gcd

        print(f'{gcd} {lcm}')
    except EOFError:
        break

Solution (Python):
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))

Solution (Python):

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)
    
    
    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()

Solution (Python):
def main():
    while True:
        try:
            a,b=(int(x) for x in input().split())
        except:
            break
        a1=a
        b1=b
        while b!=0:
            c=a%b
            a=b
            b=c
        print(a, a1*b1//a)

main()

Solution (Python):
def f(x, y):
    if x % y == 0:
        return y
    return f(y, x % y)
a = []
while True:
    try:
        a.append(list(map(int, input().split())))
    except EOFError:
        break
for i in a:
    g = f(i[0], i[1])
    l = (i[0] * i[1]) / g
    print(g, int(l))

Solution (Python):



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

Solution (Python):
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))

Solution (Python):
import sys


def euc(n,m):
    if max(n,m)%min(n,m) == 0:
        return min(n,m)
    else:
        return euc(min(n,m), max(n,m)%min(n,m))


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

Solution (Python):
def gcd(x, y):
    if x > y:
        x, y = y, x
    while x > 0:
        x, y = y%x, x
    return y

def lcm(x, y):
    z = gcd(x, y)
    return x*y//z

if __name__ == "__main__":
    while True:
        try:
            a, b = map(int, input().split())
            g = gcd(a, b)
            l = lcm(a, b)
            print("{} {}".format(g, l))
        except:
            break

Solution (Python):
import sys

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

def lcm(a,b,g):
    _a = a // g
    _b = b // g
    return _a * _b * g

def run():
    data = []
    for n in sys.stdin:
        a, b = list(map(int, n.split()))
        data.append((a,b))

    for _data in data:
        a, b = _data
        g = gcd(a,b)
        l = lcm(a,b,g)
        print(g, l)

if __name__ == '__main__':
    run()

Solution (Python):
def gcd(a, b):
    r = a % b
    if r == 0: return b
    else: return gcd(b, r)

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

while True:
    try:
        x = map(int, raw_input().split(" "))
        print "%d %d" % (gcd(x[0], x[1]), lcm(x[0], x[1]))
        
    except EOFError:
        break

Solution (Python):
import sys;print"\n".join("%d %d"%(lambda x:(x[2],x[0]/x[2]*x[1]))((lambda f,x:(x[0],x[1],f(f,x[0],x[1])))(lambda f,a,b:a%b==0 and b or f(f,b,a%b),map(int,s.split(' '))))for s in sys.stdin)

Solution (Python):
import sys
def gcd(a,b):
	if b != 0:
		return gcd(b,a%b)
	else:
		return a
def lcm(a,b,g):
	return b / g * a
for s in sys.stdin:
	ls = map(int,s.split(' '))
	print "%d %d" % (gcd(ls[0],ls[1]),lcm(ls[0],ls[1],gcd(ls[0],ls[1])))

Solution (Python):
import sys;print"\n".join("%d %d"%(lambda l:(l[0],l[2]/l[0]*l[1]))((lambda f,l:(f(f,l),l[0],l[1]))(lambda f,l:l[1]==0 and l[0] or f(f,[l[1],l[0]%l[1]]),map(int,s.split())))for s in sys.stdin)

Solution (Python):
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a%b)

def lcm(a,b):
  d = (a*b) / gcd(a,b)
  print d
while True:
  try:
   x = map(int,raw_input().split(" "))
   a,b = x[0],x[1]
   print gcd(a,b),(a*b)/gcd(a,b)

  except EOFError:
    break

Solution (Python):

while True:
    try:
        list = [int(x) for x in raw_input().split(" ")]
        list.sort(lambda x, y: y - x)
        gcd = lcm = 0
        m = list[0]
        n = list[1]
        while True:
            r = m%n
            if r == 0:
                gcd = n
                break
            m = n
            n = r
        lcm = list[0] * list[1] / gcd
        print(str(gcd) + " " + str(lcm))
    except EOFError:
        break

Solution (Python):
import sys

def gcd(a, b):
    if b == 0:
        return a
    else:
        r = a % b
        return gcd(b, r)

def calc(a, b):
    gcd_val = gcd(a, b)
    lcm_val = a * b / gcd_val
    return (gcd_val, lcm_val)


for line in sys.stdin.readlines():
    line = line.strip()
    a, b = map(int, line.split())
    print "{0[0]:d} {0[1]:d}".format(calc(a, b))

Solution (Python):
def gcd(a,b):
  if b == 0: return a
  return gcd(b,a%b)
def lcm(c,d):
   return c*d/gcd(a,b)
while True:
 try:
  a,b = map(int,raw_input().split())
  c,d = a,b
  print gcd(a,b),lcm(c,d)
 except EOFError: break

Solution (Python):


def gcd(x,y):
    r = x % y

    if r==0: return y
    else: return gcd(y,r)

def lcm(x,y):
    return x * y / gcd(x,y)

while True:
    try:
        n = map(int, raw_input().split())

        print "%d %d"%(gcd(n[0],n[1]),lcm(n[0],n[1]))

    except Exception:
        break;

Solution (Python):
import sys
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
def lcm(a,b):
    return a*b/gcd(a,b)
for i in sys.stdin.readlines():
    a,b=map(int,i.split())
    print "{} {}".format(gcd(a,b),lcm(a,b))

Solution (Python):
import sys

def gcd(x,y):
    if(y>0):
        return gcd(y,x%y)
    else:
        return x

def lcm(x,y):
    return x/gcd(x,y)*y

for x in sys.stdin.readlines():
    n = [float(y) for y in x.split()]

    print "%d %d" % (gcd(n[0], n[1]),(lcm(n[0], n[1])))

Solution (Python):

def GCM(m, n):
    while 1:
        if n == 0: return m
        m -= (m/n)*n
        m,n = n,m
    
while 1:
    try:
        a,b = map(int, raw_input().split())
        x = GCM(a,b)
        y = a*b / x
        print "%d %d" % (x, y)
    except EOFError:
        break

Solution (Python):

while True:
    try:
        x = map(int, raw_input().split(' '))
        
        if x[0] < x[1]:
            m = x[1]
            n = x[0]
        else:
            m = x[0]
            n = x[1]
           
           
        
        while n !=0:
            m,n = n,m % n
        
        print m,x[0]*x[1]/m
    except EOFError:
        break

Solution (Python):
def swap(a, b):
    a = a ^ b
    b = a ^ b
    a = a ^ b
def gcd(x, y):
    if(x < y):
        swap(x, y)
    mod = x % y
    if mod == 0:
        return y
    else:
        return gcd(y, mod)
def lcm(x, y):
    return x * y / gcd(x, y)
while True:
    try:
        (a, b) = map(int ,raw_input().split())
    except EOFError:
        break
    print gcd(a, b), lcm(a, b)

Solution (Python):
def gcd(a, b):
    if b == 0: return a
    else: return gcd(b, a % b)

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

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

Solution (Python):
def gcd(a, b):
    r = a % b
    if r == 0: return b
    else: return gcd(b, r)
 
def lcm(a, b):
    return a*b/gcd(a,b)
 
while True:
    try:
        x = map(int, raw_input().split(" "))
        print "%d %d" % (gcd(x[0], x[1]), lcm(x[0], x[1]))
         
    except EOFError:
        break

Solution (Python):

import sys

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

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

for l in sys.stdin:
    a = [int(s) for s in l.split()]
    print str(gcd(a[0],a[1]))+" "+str(lcm(a[0],a[1]))

Solution (Python):
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
import sys
from fractions import gcd
from itertools import count

for line in sys.stdin:
    small, large = sorted(int(n) for n in line .split())
    for i in count(large, large):
        if not i % small:
            lcm = i
            break
    print(gcd(large, small), lcm)

Solution (Python):
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
import sys
from fractions import gcd

for line in sys.stdin:
    small, large = sorted(int(n) for n in line .split())
    G = gcd(large, small)
    print(G, large // G * small)

Solution (Python):
import sys

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

for l in sys.stdin:
    a,b=map(int,l.split())
    d=gcd(a,b)
    print d,a/d*b

Solution (Python):
while True:
	try:
		while True:
			ints = raw_input()
			if ints != '':
				x = map(int,ints.split(' '))
				x.sort()
				a = x[1]
				b = x[0]
				while True:
					m=a%b
					if m!=0:
						a=b
						b=m
						continue
					else:
						break
				n = x[1]*x[0]/b
				print b,n
				continue
			else:
				break
	except: break

Solution (Python):
import sys
def gcd(a,b):
    if (b == 0):
        return a
    return gcd(b,a%b)
for line in sys.stdin:
    a,b = [int(x) for x in line.split()]
    d = gcd(a,b)
    print d,a*b/d

Solution (Python):
import sys
def g(a,b):
    if b==0: return a
    return g(b,a%b)
for l in sys.stdin:
    a,b=map(int,l.split())
    c=g(a,b)
    print c,a/c*b

Solution (Python):
while True:
    try:
        a = map(int,raw_input().split())

	n = [a[0],a[1]]

        while True:
            if a[0] < a[1]:
	        tmp = a[0]
                a[0] = a[1]
	        a[1] = tmp

            a[0] = a[0] - a[1]
	    if a[0] == 0:
		break

	b = n[0]*n[1]/a[1]

	print "%d %d" % (a[1],b)

    except EOFError:
	break

Solution (Python):

import sys
import fractions
import re


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





for line in sys.stdin:
    ab = map(int, re.split(" +", line))
    a, b = tuple(ab)
    gcd_ab = fractions.gcd(a, b)
    lcm_ab = lcm(a, b)
    print gcd_ab, lcm_ab

Solution (Python):
while True:
	try:
		n = map(int, raw_input().split())
		a = max(n) 
		b = min(n)
		ab = a * b
		while b != 0 :
			c = a % b
			a = b
			b = c
		print str(a) + " " + str(ab / a)
	except EOFError:
		break

Solution (Python):
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)

try :
  while True :
    (a,b) = map(int, raw_input().split())

    print gcd(a,b), lcm(a,b)
except EOFError :
  pass

Solution (Python):
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a

while True:
    try:
        a,b = map(int, raw_input().split())
        c = gcd(a, b)
        print "{0} {1}".format(c, a*b/c)
    except:
        break

Solution (Python):
import sys

def gcd(a, b):
    return gcd(b, a % b) if a % b else b

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

for line in sys.stdin:
    data = map(int, line.split())
    a, b = data
    print "%d %d" % (gcd(a, b), lcm(a, b))

Solution (Python):
def gcm(a, b):
    if a<b: a,b = b,a

    if (a%b ==0):
        return b
    else:
        return gcm(b, a%b)

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

while True:
    try:
        a, b = map(int, raw_input().split())
    except:
        break
    print "%d %d" %(gcm(a,b), lcm(a,b))

Solution (Python):
import fractions

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

Solution (Python):


import sys


def gcd(x, y):
	while x != y:
		if x > y:
			x -= y
		else:
			y -= x
	return x

datas = []

for line in sys.stdin:
	datas.append(map(int, line.split()))

for data in datas:
	g = gcd(data[0], data[1])
	print "{0} {1}".format(g, data[0] * data[1] / g)

Solution (Python):
import sys

for line in sys.stdin:
    a, b = sorted(map(int, line.split(' ')))
    gcd = 1
    d = 2
    while a >= d:
        amod, bmod = a % d, b % d
        if amod == 0 and bmod == 0:
            gcd *= d
            a, b = a/d, b/d
            d = 2
            continue
        else:
            d += 1
    lcm = gcd * a * b
    print gcd, lcm

Solution (Python):
while 1:
        try:
                a, b = map(int,raw_input().split())
        except EOFError:
                break
        ac, bc = a, b
        while 1:
                if a < b:
                        b = b - a
                elif b < a:
                        a = a - b
                elif a == b:
                        x = [a,ac*bc/a]
                        print "{:.10g} {:.10g}".format(*x)
                        break

Solution (Python):
import sys

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)

for s in sys.stdin:
	i = map(int,s.split())
	print gcd(*i), lcm(*i)

Solution (Python):
import sys
def gcm(a, b):
    if a<b: a,b=b,a
    if (a%b==0):
        return b
    else:
        return gcm(b,a%b)

for s in sys.stdin:
    a,b=map(int,s.split())
    c=gcm(a,b)
    print "%d %d" %(c,a/c*b)

Solution (Python):
import sys
def gcm(a,b):
    if a<b: a,b=b,a
    if (a%b==0): return b
    return gcm(b,a%b)

for s in sys.stdin:
    a,b=map(int,s.split())
    c=gcm(a,b)
    print "%d %d" %(c,a/c*b)

Solution (Python):
import sys
def gcm(a,b):
    if a%b==0: return b
    return gcm(b,a%b)

for s in sys.stdin:
    a,b=map(int,s.split())
    c=gcm(a,b)
    print c,a/c*b

Solution (Python):
import sys
def gcm(a,b):
    if a%b==0: return b
    return gcm(b,a%b)

for s in sys.stdin:
    a,b=map(int,s.split())
    if a<b:a,b=b,a
    c=gcm(a,b)
    print c,a/c*b

Solution (Python):
import sys
def gcm(a,b):
    if b==0: return a
    return gcm(b,a%b)

for s in sys.stdin:
    a,b=map(int,s.split())
    if a<b:a,b=b,a
    c=gcm(a,b)
    print c,a/c*b

Solution (Python):
import sys
def gcm(a,b):
    if b==0: return a
    return gcm(b,a%b)

for s in sys.stdin:
    a,b=map(int,s.split())
    c=gcm(a,b)
    print c,a/c*b

Solution (Python):
import sys
for i in sys.stdin:
	m, n = map(int, i.split())
	t1, t2 = m, n
	while True:
		if m % n == 0:
			break
		m, n = n, m % n
	a = n
	b = (t1/ a) * t2
	print("{} {}".format(a, b))

Solution (Python):
import sys
def gcm(a,b):
    return gcm(b,a%b) if b else a
for s in sys.stdin:
    a,b=map(int,s.split())
    c=gcm(a,b)
    print c,a/c*b

Solution (Python):
import sys
def gcm(a,b):
    x=gcm(b,a%b) if b else a
    return x
for s in sys.stdin:
    a,b=map(int,s.split())
    c=gcm(a,b)
    print c,a/c*b

Solution (Python):
import sys
def g(a,b):
  x=g(b,a%b) if b else a
  return x
for s in sys.stdin:
  a,b=map(int,s.split())
  c=g(a,b)
  print c,a/c*b

Solution (Python):


import sys

def isprime(n):
    for i in xrange(2, int(n ** 0.5)+1 ):
        if n % i == 0: return False
    return True


outList = []
for line in sys.stdin.readlines():
    List = map(int, line.strip().split())

    [a, b] = List

    
    LCM = 1
    i = 1
    while( i <= min(a, b) ):
        i += 1
        if not isprime(i): continue
        while(a % i == 0 and b % i == 0):
            LCM *= i
            a /= i
            b /= i

    
    GCD = List[0] * b

    print LCM, GCD

Solution (Python):
gcd, lcm = [], []
while True:
	try:
		a, b = map(int, raw_input().split())
		if a > b:
			m, n = a, b
		else:
			m, n = b, a		

		while n != 0:
			m, n = n, m % n 
		gcd.append(m)
		lcm.append(a * b / m)
	except EOFError:
		break

for gcd, lcm in zip(gcd, lcm):
	print '%d %d' % (gcd, lcm)

Solution (Python):
while True:
    try:
        a, b = map(int, raw_input().split())
        def gcd(a, b):
            if b == 0:
                return a
            else:
                return gcd(b, a%b)
        g = gcd(a,b)
        l = a*b/g
        print g, l
    except:
        break

Solution (Python):
import sys

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

for line in sys.stdin:
    (a,b)=line.split(" ")
    a=eval(a)
    b=eval(b)
    g=gcd(a,b)
    print("%d %d" % (g,a*b/g))

Solution (Python):

def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    else:
        return gcd(b, r)

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

while True:
    try:
        a, b = map(int, raw_input().split())
    except EOFError:
        break

    g = gcd(a, b) 
    print "{} {}".format(g, lcm(a,b,g))

Solution (Python):
def get_gcd(a,b):
	if a > b: a, b = b, a
	if b % a == 0:
		return a
	else:
		return get_gcd(a, b % a)

def get_lcm(a,b,g):
	return a * b / g

while True:
	try:
		a,b = map(int, sorted(raw_input().split()))
		GCD = get_gcd(a,b)
		LCM = get_lcm(a,b,GCD)
		print "{} {}".format(GCD, LCM)
	except EOFError:
		break

Solution (Python):
import sys

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

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

for ab in sys.stdin:
    a,b=map(int, ab.split())
    a,b=max(a,b),min(a,b)
    print gcd(a,b),lcm(a,b)

Solution (Python):
from fractions import gcd
while 1:
    try:
        a, b = map(int, raw_input().split())
        print gcd(a, b), a * b / gcd(a, b)
    except:
        break

Solution (Python):
def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


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

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

Solution (Python):

import sys


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


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

for s in sys.stdin:
  a, b = map(int,s.split())
  gcd_num = gcd(a, b)
  lcm_num = lcm(a, b)
  print "%d %d"%(gcd_num, lcm_num)

Solution (Python):
import fractions
while True:
	try:
		x,y = map(int,raw_input().split())
		print '%d %d' % (fractions.gcd(x,y),x/fractions.gcd(x,y)*y)
	except EOFError:
		break

Solution (Python):
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)

Solution (Python):
import sys

def readint():
    for line in sys.stdin:
        yield map(int,line.split())

def gcd(x,y):
    [x,y] = [max(x,y),min(x,y)]
    while 1:
        z = x % y
        if z == 0:
            break
        [x,y] = [y,z]
    return y

for [x,y] in readint():
    GCD = gcd(x,y)
    mx = x/GCD
    print GCD,mx*y

Solution (Python):
def gcd(u, v):
    if (v == 0): return u
    return gcd(v, u % v)

def lcm(u, v):
    return (u * v) // gcd(u, v)

while 1:
    try:
        inp = input()
    except EOFError:
        break
    else:
        u, v = inp.split(' ')
        u = int(u)
        v = int(v)
        print(gcd(u, v), lcm(u, v))

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

Solution (Python):
def gcd(y, x):
    if x == 0:
        return y
    return gcd(x, y%x)
try:
    while True:
        a, b = sorted(map(int, input().split()), reverse=True)
        print(gcd(a,b), a*b//gcd(a,b))
except:
    pass

Solution (Python):

import math
errerN=1

while errerN:
    try:
        a=list(map(int, input().split()))
        gcdN=math.gcd(a[0],a[1])
        print(gcdN, int(a[0]*a[1]/gcdN))
    except :
        errerN=0

Solution (Python):
def gcd(a, b) :
    if a % b == 0 :
        return b
    else :
        return gcd(b, a % b)

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

Solution (Python):

while True:
    try:

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

        a = list(map(int,input().split()))
        a.sort()
        a.reverse()
        ans1 = gcd(a[0],a[1])
        ans2 = int(a[0]*a[1]/ans1)

        print(ans1,ans2)
    except:
        break

Solution (Python):
def gcd(a, b) :
    if a % b == 0 :
        return b
    else :
        return gcd(b, a % b)

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

Solution (Python):
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:
        break

Solution (Python):
while True:
    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)

    try:
        a, b = map(int, input().split())
    except EOFError:
        break
    print(str(gcd(b, a%b)) + " " + str(int(lcm(a, b))))

Solution (Python):
while True:
    try:
        lst = list(map(int, input().split()))
        a, b = lst[0], lst[1]
        while b != 0:
            a, b = b, a % b
            
        c = lst[0]* lst[1]/ a
        print('{:.0f}'.format(a), end = " ")
        print('{:.0f}'.format(c))

    except:
        break

Solution (Python):
import math
while True:
    try:
        a,b=(map(int,input().split()))
        x=math.gcd(a,b)
        y=a*b//x
        print(x,y)
    except EOFError:
        break

Solution (Python):
import math
john=[]
while True:
    try:
        john.append(input())
    except EOFError:
        break
for i in john:
    k=list(map(int,i.split()))
    print(int(math.gcd(k[0],k[1])),int(k[0]*k[1]/math.gcd(k[0],k[1])))

Solution (Python):
import math
import sys
def gcd(a,b):
    if b==0:
        return a
    return gcd(b, a%b)
def lcm(a,b):
    return a/gcd(a,b)*b
for l in sys.stdin:
    a=list(map(int,l.split()))
    print("%d %d"%(gcd(a[0],a[1]),lcm(a[0],a[1])))

Solution (Python):
def gcd(a:int, b:int):
    if b == 0:
        return a
    
    return gcd(b,a%b)

def main():
    while 1:
        try:
            a = list(map(int, input().split()))
            b = gcd(a[0],a[1])
            c = a[0]/b*a[1]
            print('%s %d' % (b,c))
        except:
            break
            
if __name__ == "__main__":
    main()

Solution (Python):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b,a%b)

def main():
    while 1:
        try:
            a = list(map(int, input().split()))
            b = gcd(a[0],a[1])
            c = a[0]/b*a[1]
            
            print('%d %d' % (b,c))
        except:
            break
            
main()

Solution (Python):
def GCD(a,b):
    if(b==0):
        return a 
    return GCD(b,a%b)

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


while True:
    try:
        x = list(map(int,input().split()))
        ans_1 = GCD(x[0],x[1])
        ans_2 = LCM(x[0],x[1])
        print("%d %d"%(ans_1,ans_2))
    
    except:
        break

Solution (Python):
def gcd(a,b):
    if(b==0):
        return a 
    return gcd(b,a%b)

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

Solution (Python):

import math
try:
    while True:
        a,b = map(int,input().split())
        
        num1 = math.gcd(a,b)
        
        num2 = int(a * b / num1)
        print(str(num1) + " " + str(num2))

except EOFError:
    pass

Solution (Python):
def gcd(m, n):
    while n:
        m, n = n, m % n
    return m
def lcm(m, n):
    return m // gcd(m, n) * n

for line in open(0).readlines():
    a, b = map(int, line.split())
    print(gcd(a, b), lcm(a, b))

Solution (Python):
import math

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

Solution (Python):
import math
while True:
    try :
        a,b = map(int,input().split())
        gcd = math.gcd(a,b)
        c= a/gcd
        d= b/gcd
        print(gcd,int(c*d*gcd))
    except EOFError:
        break

Solution (Python):
import sys
import math
def gcd(x,y):
    if(x%y==0):
        return y
    else:
        return(gcd(y,x%y))
try:
    while True:
        a,b= map(int, input().split())
        max1=gcd(a,b)
        min1=(a*b)//gcd(a,b)
        print(str(max1)+' '+str(min1))
except EOFError:
    pass

Solution (Python):
import math

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

Solution (Python):
def gcd(aa, bb):
    if aa % bb == 0:
        return bb
    return gcd(bb, aa % bb)

import sys
for line in sys.stdin.readlines():
    ab = list(map(int, line.split()))
    a = max(ab)
    b = min(ab)
    g = gcd(a, b)

    print(g, a * b // g)

Solution (Python):
def gcd(x,y):
    return gcd(y,x % y) if y > 0 else x

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

while(1):
    try:
        x,y = (int(x) for x in input().split())
        print(gcd(x,y),lcm(x,y))
    except:
        break

Solution (Python):
import math

while True:
    try:
        a, b = list(map(int, input().split()))
        print('{0} {1}'.format(math.gcd(a, b), int(a * b / math.gcd(a, b))))
    except EOFError:
        break

Solution (Python):
import math

try:
    while True:
        a, b = list(map(int, input().split()))
        print("{} {}".format(math.gcd(a, b), (a * b) // math.gcd(a, b)))
except Exception as _:
    pass

Solution (Python):
import math
while True:
    try:
        a = list(map(int,input().split()))
        b = (math.gcd(a[0],a[1]))
        c = ((a[0]*a[1])//math.gcd(a[0],a[1]))
        print(b,c)
    except EOFError:
        break

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

Solution (Python):

import sys

def gcd(x, y):
    return y if not x%y else gcd(y, x%y)

def get_input():
    data = []
    for line in sys.stdin:
        a, b = [int(i) for i in line.split()]
        data.append((a,b))
    return data


data = get_input()

for x,y in data:
    GCD = gcd(x,y)
    LCM = x*y // GCD
    print(GCD, LCM)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
import fileinput

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

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


for line in sys.stdin:
    x, y = map(int, line.split())
    print(gcd(x,y),lcm(x,y))

Solution (Python):
import fileinput


def GCD(x, y):
    if y != 0:
        return GCD(y, x % y)
    else:
        return x

for line in fileinput.input():
    x, y = [int(s) for s in line.split()]
    
    print(GCD(x, y),int(x * y/GCD(x, y)))

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