def euclid(n,m): if n > m: a = n b = m else: a = m b = n while b != 0: a = a % b a , b = b , a return a n1 =int(input()) list1 =list(map(int,input().split())) n2 =int(input()) list2 =list(map(int,input().split())) nume =list1[0] deno =list2[0] for i in range(n1-1): deno *= list1[i+1] for i in range(n2-1): nume *= list2[i+1] gcd = euclid(nume,deno) if deno < 0: nume *= -1 deno *= -1 print(nume//gcd,deno//gcd)