n = int(input()) A = list(map(int,input().split())) m = int(input()) B = list(map(int,input().split())) def gcd(a,b): while True: r = a % b a = b b = r if r == 0: return a si = A[0] bo = 1 for a in A[1:]: bo *= a for i in range(0,m,2): bo *= B[i] for i in range(1,m,2): si *= B[i] d = gcd(abs(si),abs(bo)) si //= d bo //= d if bo < 0: si *= -1 bo *= -1 print(si,bo)