import fractions import functools def main(): _ = input() xs = [fractions.Fraction(int(x), 1) for x in input().split()] f = functools.reduce(lambda f1, f2: f1 / f2, xs) # print(f) _ = input() ys = [fractions.Fraction(int(x), 1) for x in input().split()] g_upper = functools.reduce(lambda f1, f2: f1 * f2, ys[::2], initial=1) g_lower = functools.reduce(lambda f1, f2: f1 * f2, ys[1::2], initial=1) g = g_upper / g_lower # print(g) res = f / g if res.denominator >= 0: print(res.numerator, res.denominator) else: print(-res.numerator, -res.denominator) if __name__ == '__main__': main()