n = int(eval(input()))

l = [int(eval(input())) for _ in range(n)]

from fractions import gcd



def lcm(l):

  x = l[0]

  for i in range(1, len(l)):

    x = (x * l[i]) // gcd(x, l[i])

  return x



print((lcm(l)))
n = int(eval(input()))

t = [int(eval(input())) for _ in range(n)]



from fractions import gcd





def lcm(t):

  x = t[0]

  for i in range(1, len(t)):

    x = (x * t[i]) // gcd(x, t[i])

  return x  



print((lcm(t)))
n = int(eval(input()))
l = [int(eval(input())) for _ in range(n)]
from fractions import gcd


def lcm(l):
    x = l[0]
    for i in range(1, len(l)):
        x = (x * l[i]) // gcd(x, l[i])
    return x


print((lcm(l)))

n = int(eval(input()))
t = [int(eval(input())) for _ in range(n)]
from fractions import gcd


def lcm(t):
    x = t[0]
    for i in range(1, len(t)):
        x = (x * t[i]) // gcd(x, t[i])
    return x


print((lcm(t)))

-l = [int(eval(input())) for _ in range(n)] +t = [int(eval(input())) for _ in range(n)] -def lcm(l): -    x = l[0] -    for i in range(1, len(l)): -        x = (x * l[i]) // gcd(x, l[i]) +def lcm(t): +    x = t[0] +    for i in range(1, len(t)): +        x = (x * t[i]) // gcd(x, t[i]) -print((lcm(l))) +print((lcm(t)))