n = int(input()) *a, = map(int,input().split()) m = int(input()) *b, = map(int,input().split()) p = a[0] q = 1 for i in a[1:]: q *= i for i in b[m-1::-2]: p *= i for i in b[m-2::-2]: q *= i from math import gcd g = gcd(p,q) p //= g; q //= g if q < 0: p,q = -p,-q print(p,q)