import math N1 = int(input()) lsA = list(map(int,input().split())) N2 = int(input()) lsB = list(map(int,input().split())) lsc = lsA[0] lsp = 1 for i in range(1,N1): lsp *= lsA[i] for i in range(N2): if i % 2 == 0: lsp *= lsB[i] else: lsc *= lsB[i] gcd = math.gcd(lsc, lsp) if lsc*lsp < 0: print(-abs(lsc//gcd),abs(lsp//gcd)) elif lsc < 0 and lsp < 0: print(abs(lsc//gcd),abs(lsp//gcd)) else: print(lsc//gcd,lsp//gcd)