from fractions import Fraction from functools import reduce from operator import mul def main(): n1 = int(input()) a = list(map(int, input().split())) n2 = int(input()) b = list(map(int, input().split())) x = Fraction(a[0], reduce(mul, a[1:])) if n1 > 1 else a[0] y = Fraction(reduce(mul, b[1::2]), reduce(mul, b[0::2])) if n2 > 1 else b[0] ans = Fraction(x * y) print(ans.numerator, ans.denominator) if __name__ == "__main__": main()