def frac(f):
    a,b = f
    while b:
        a, b = b, a%b
    return (f[0]//(a or 1), f[1]//(a or 1))


# # # test # # #
t = """4 8
1536 78360
51478 5536
46410 119340
7673 4729
4096 1024"""
for line in t.splitlines():
    ans = frac(tuple(map(int, line.split())))
    print(' '.join(map(str, ans)))