A,B = list(map(int,input().split()))

a,b = A,B

while True:

    if a > b:

        b += B

    elif a < b:

        a += A

    if a == b:

        print(a)

        break
A,B = list(map(int,input().split()))



def gcd(a, b):

    if a % b == 0:

        return b

    else:

        return gcd(b, a % b)



def lcm(a, b):

    return a / gcd(a, b) * b



print((int(lcm(A,B))))
A, B = list(map(int, input().split()))
a, b = A, B
while True:
    if a > b:
        b += B
    elif a < b:
        a += A
    if a == b:
        print(a)
        break

A, B = list(map(int, input().split()))


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


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


print((int(lcm(A, B))))

-a, b = A, B -while True: -    if a > b: -        b += B -    elif a < b: -        a += A -    if a == b: -        print(a) -        break + + +def gcd(a, b): +    if a % b == 0: +        return b +    else: +        return gcd(b, a % b) + + +def lcm(a, b): +    return a / gcd(a, b) * b + + +print((int(lcm(A, B))))