inf = open("gcm.in", "r")
ouf = open("gcm.out", "w")

def factor(x):
    i = 2
    res = []
    while i * i <= x:
        if x % i == 0:
            div = i
            cnt = 1
            res.append((div, cnt))
        i += 1
    if x != 1:
        res.append((x, 1))
    return res

a, b = map(int, inf.readline().split())
af = factor(a)
bf = factor(b)

ap = 0
bp = 0
allf = []
while ap < len(af) or bp < len(bf):
    if ap < len(af) and bp < len(bf) and af[ap][0] == bf[bp][0]:
        allf.append((af[ap][0], min(af[ap][1], bf[bp][1]), max(af[ap][1], bf[bp][1])))
        ap += 1
        bp += 1
    elif ap < len(af) and (bp == len(bf) or af[ap][0] < bf[bp][0]):
        allf.append((af[ap][0], 0, af[ap][1]))
        ap += 1
    else:
        allf.append((bf[bp][0], 0, bf[bp][1]))
        bp += 1

ans = (min(a, b), max(a, b))

def bt(a, p, x, y):
    global ans
    if p == len(a):
        if 0 <= y - x < ans[1] - ans[0]:
            ans = (x, y)
        return
    mx = a[p][0] ** a[p][2]
    cr = a[p][0] ** a[p][1]
    bt(a, p + 1, x * mx, y * cr)
    bt(a, p + 1, x * cr, y * mx)

bt(allf, 0, 1, 1)

print(ans[0], ans[1], file = ouf)

inf.close()
ouf.close()

