n = int(eval(input()))

a = list(map(int, input().split()))[::-1]



min_ans = 2

max_ans = 2



for i in range(n):

    min_ans = -((-min_ans) // a[i]) * a[i]

    

for i in range(n):

    max_ans = (max_ans// a[i]) * a[i] +a[i] - 1



a = a[::-1]

tmp_ans = min_ans

tmp_ans2 = max_ans

for i in range(n):

    tmp_ans = (tmp_ans // a[i]) * a[i]

    tmp_ans2 = (tmp_ans // a[i]) * a[i]

    

if tmp_ans == 2 and tmp_ans2 == 2:

    print((min_ans, max_ans))

else:

    print((-1))
k = int(eval(input()))

a = list(map(int, input().split()))



max_ans = 2

for i in range(k)[::-1]:

    max_ans = (max_ans // a[i]) * a[i] + (a[i] - 1)

    

min_ans = 2

for i in range(k)[::-1]:

    min_ans = -((-min_ans) // a[i]) * a[i]



tmp = max_ans

for i in range(k):

    tmp = (tmp // a[i]) * a[i]

if tmp != 2:

    print((-1))

    exit()

    

tmp = min_ans

for i in range(k):

    tmp = (tmp // a[i]) * a[i]

if tmp != 2:

    print((-1))

    exit()



print((min_ans, max_ans))
n = int(eval(input()))
a = list(map(int, input().split()))[::-1]
min_ans = 2
max_ans = 2
for i in range(n):
    min_ans = -((-min_ans) // a[i]) * a[i]
for i in range(n):
    max_ans = (max_ans // a[i]) * a[i] + a[i] - 1
a = a[::-1]
tmp_ans = min_ans
tmp_ans2 = max_ans
for i in range(n):
    tmp_ans = (tmp_ans // a[i]) * a[i]
    tmp_ans2 = (tmp_ans // a[i]) * a[i]
if tmp_ans == 2 and tmp_ans2 == 2:
    print((min_ans, max_ans))
else:
    print((-1))

k = int(eval(input()))
a = list(map(int, input().split()))
max_ans = 2
for i in range(k)[::-1]:
    max_ans = (max_ans // a[i]) * a[i] + (a[i] - 1)
min_ans = 2
for i in range(k)[::-1]:
    min_ans = -((-min_ans) // a[i]) * a[i]
tmp = max_ans
for i in range(k):
    tmp = (tmp // a[i]) * a[i]
if tmp != 2:
    print((-1))
    exit()
tmp = min_ans
for i in range(k):
    tmp = (tmp // a[i]) * a[i]
if tmp != 2:
    print((-1))
    exit()
print((min_ans, max_ans))

-n = int(eval(input())) -a = list(map(int, input().split()))[::-1] +k = int(eval(input())) +a = list(map(int, input().split())) +max_ans = 2 +for i in range(k)[::-1]: +    max_ans = (max_ans // a[i]) * a[i] + (a[i] - 1) -max_ans = 2 -for i in range(n): +for i in range(k)[::-1]: -for i in range(n): -    max_ans = (max_ans // a[i]) * a[i] + a[i] - 1 -a = a[::-1] -tmp_ans = min_ans -tmp_ans2 = max_ans -for i in range(n): -    tmp_ans = (tmp_ans // a[i]) * a[i] -    tmp_ans2 = (tmp_ans // a[i]) * a[i] -if tmp_ans == 2 and tmp_ans2 == 2: -    print((min_ans, max_ans)) -else: +tmp = max_ans +for i in range(k): +    tmp = (tmp // a[i]) * a[i] +if tmp != 2: +    exit() +tmp = min_ans +for i in range(k): +    tmp = (tmp // a[i]) * a[i] +if tmp != 2: +    print((-1)) +    exit() +print((min_ans, max_ans))