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[1::2]: p *= i for i in b[::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)