from functools import reduce from fractions import Fraction from sys import stdin def main(): N1 = int(input()) A = list(map(int, input().split())) N2 = int(input()) B = list(map(int, input().split())) a = reduce(Fraction, A) b = B[-1] if N2 > 1: for i in range(N2 - 2, -1, -1): b = Fraction(B[i], b) ans = a / b print(ans.numerator, ans.denominator) input = lambda: stdin.readline() main()