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[0], 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[0], B[1]) for i in range(2, n2): b = b * Fraction(1, B[i]) c = a / b print(c.numerator) print(c.denominator)