import math alen = int(input()) A = list(map(int,input().split())) blen = int(input()) B = list(map(int,input().split())) C = [] P = [] sig = 1 for i in range(alen): if i==0: C.append(A[i]) else: P.append(A[i]) sig*=A[i] for i in range(blen): if (i+blen)%2==1: C.append(B[i]) else: P.append(B[i]) sig*=B[i] sig = sig//abs(sig) c = 1 p = 1 for i in C: c *= i for i in P: p *= i gcd = math.gcd(abs(c),abs(p)) print(sig*abs(c)//gcd,abs(p)//gcd)