import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from functools import reduce from operator import mul from fractions import Fraction NA = int(readline()) A = tuple(map(int,readline().split())) NB = int(readline()) B = tuple(map(int,readline().split())) num = [] den = [] num.append(A[0]) den += A[1:] num += B[1::2] den += B[::2] n = reduce(mul, num, 1) d = reduce(mul, den, 1) answer = Fraction(n,d) print(answer.numerator, answer.denominator)