from functools import reduce from fractions import Fraction from sys import stdin def main(): _ = int(input()) A = list(map(int, input().split())) _ = int(input()) B = list(map(int, input().split())) a = reduce(Fraction, A) b = reduce(Fraction, B) ans = Fraction(a, b) print(ans.numerator, ans.denominator) input = lambda: stdin.readline() main()