from fractions import Fraction n1 = int(input()) A = list(map(int, input().split())) n2 = int(input()) B = list(map(int, input().split())) a = Fraction(A[0], 1) b = Fraction(B[n2 - 1], 1) if n1 > 1: a = Fraction(A[0], A[1]) for i in range(2, n1): a = a * Fraction(1, A[i]) if n2 > 1: b = Fraction(B[n2 - 2], B[n2 - 1]) for i in range(n2 - 3, -1, -1): b = B[i] / b c = a / b print(c.numerator, c.denominator)