from math import gcd import sys if len(sys.argv) == 2: sys.stdin = open(sys.argv[1]) n1 = int(input()) A = list(map(int, input().split())) numerator = A[0] denominator = 1 for i in range(1, n1): denominator *= A[i] n2 = int(input()) B = list(map(int, input().split())) for i in range(n2): if i % 2 == 0: denominator *= B[i] else: numerator *= B[i] gcd_n = gcd(numerator, denominator) if denominator // gcd_n < 0: gcd_n *= -1 print(numerator // gcd_n, denominator // gcd_n)