n_1=int(input()) A=list(map(int,input().split())) n_2=int(input()) B=list(map(int,input().split())) up,down=A[0],1 A=A[1:] import math for i in A: down*=i for i,j in enumerate(B): if i%2==0: down*=j else: up*=j print(up//math.gcd(up,down),down//math.gcd(up,down))