import math n = int(input()) a = map(int, input().split(' ')) m = int(input()) b = map(int, input().split(' ')) (a[0], b[0]) = (b[0], a[0]) cnt = False for i in range(n): if a[i] < 0: a[i] = -a[i] cnt = not cnt for i in range(m): if b[i] < 0: b[i] = -b[i] cnt = not cnt A = 1 B = 1 for i in a: A *= i for i in b: B *= i g = math.gcd(A, B) if cnt: B = -B print(B//g, A//g)