# -*- 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::2]) Y = reduce(operator.mul, A[1:] + B[::2]) Z = gcd(X, Y) if Y < 0: X *= -1 Y *= -1 print(X//Z, Y//Z)