#!/usr/bin/env python3 # † from fractions import Fraction as frac from functools import reduce ### if __name__ == '__main__': input() a = list(map(int, input().split())) input() b = list(map(int, input().split())) nume = reduce(lambda x, y: frac(x, y), a) deno = reduce(lambda x, y: frac(y, x), reversed(b)) res = frac(nume, deno) print(res.numerator, res.denominator)