from fractions import Fraction as fra na=int(input()) la=list(map(int,input().split())) nb=int(input()) lb=list(map(int,input().split())) if na == 1: a=fra(1,1) else: a=fra(la[0],la[1]) for i in range(2,na): a=a*fra(1,la[i]) if nb == 1: b=fra(1,1) else: b=fra(lb[0],lb[1]) for i in range(2,nb): b=b*fra(1,lb[i]) ans=a/b print(ans.numerator, ans.denominator)