N1 = int(input()) A = list(map(int,input().split())) N2 = int(input()) B = list(map(int,input().split())) daut = 1 mot = 1 for i in range(N1): if i == 0: daut *= A[i] else: mot *= A[i] for i in range(N2): if i % 2 == 0: mot *= B[i] else: daut *= B[i] a = 1 if mot * daut < 0: a = -1 mot = abs(mot) daut = abs(daut) from math import gcd x = gcd(mot,daut) print(daut//x * a,mot//x)