n1 = int(input()) A = list(map(int, input().split())) n2 = int(input()) B = list(map(int, input().split())) x = A[0] y = 1 for i in range(1, n1): y *= A[i] for i in range(n2): if i%2 == 0: y *= B[i] else: x *= B[i] import math if x*y > 0: g = math.gcd(x, y) a, b = abs(x)//g, abs(y)//g else: g = math.gcd(abs(x), abs(y)) a, b = -abs(x)//g, abs(y)//g print(a, b)