N1 = int(input()) A = list(map(int,input().split())) N2 = int(input()) B = list(map(int,input().split())) L = 1 for k in range(1,N1): L *= A[k] L *= B[0] U = 1 for k in range(1,N2): U *= B[k] U *= A[0] def gcd(a,b): if b == 0: return a return gcd(b,a%b) P = gcd(U,L) print(U//P,L//P)