import math from functools import reduce from operator import mul n = int(input()) a = list(map(int, input().split())) m = int(input()) b = list(map(int, input().split())) a1 = a[0] a2 = reduce(mul, a[1:]) b1 = b2 = 1 for i in range(m): if i % 2 == 0: b1 *= b[i] else: b2 *= b[i] ans1 = a1 * b2 ans2 = a2 * b1 gcd = math.gcd(ans1, ans2) print(ans1//gcd, ans2//gcd)