# -*- coding: utf-8 -*-
import operator
from functools import reduce
from math import gcd
def inpl(): return list(map(int, input().split()))

n1 = int(input())
A = inpl()
n2 = int(input())
B = inpl()

X = reduce(operator.mul, [A[0]] + B[1:])
Y = reduce(operator.mul, [B[0]] + A[1:])

Z = gcd(X, Y)

if Y < 0:
    X *= -1
    Y *= -1

print(X//Z, Y//Z)