N = int(eval(input()))

a = [int(eval(input())) for i in range(N)]

import fractions

ans = a[0]

for i in range(1, N):

    ans = ans * a[i] // fractions.gcd(ans, a[i])

print(ans)
N = int(eval(input()))

T = [int(eval(input())) for i in range(N)]

import fractions

from functools import reduce



def lcm_base(x, y):

    return (x * y) // fractions.gcd(x, y)



def lcm(*numbers):

    return reduce(lcm_base, numbers, 1)



def lcm_list(numbers):

    return reduce(lcm_base, numbers, 1)



print((lcm_list(T)))
N = int(eval(input()))
a = [int(eval(input())) for i in range(N)]
import fractions

ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
print(ans)

N = int(eval(input()))
T = [int(eval(input())) for i in range(N)]
import fractions
from functools import reduce


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


print((lcm_list(T)))

-a = [int(eval(input())) for i in range(N)] +T = [int(eval(input())) for i in range(N)] +from functools import reduce -ans = a[0] -for i in range(1, N): -    ans = ans * a[i] // fractions.gcd(ans, a[i]) -print(ans) + +def lcm_base(x, y): +    return (x * y) // fractions.gcd(x, y) + + +def lcm(*numbers): +    return reduce(lcm_base, numbers, 1) + + +def lcm_list(numbers): +    return reduce(lcm_base, numbers, 1) + + +print((lcm_list(T)))