#!/usr/bin/env python3 import math n1 = int(input()) a = list(map(int, input().split())) n2 = int(input()) b = list(map(int, input().split())) num = a[0] den = 1 for a_i in a[1 :]: den *= a_i for i, b_i in enumerate(b): if i % 2 == 0: den *= b_i else: num *= b_i gcd = math.gcd(num, den) num //= gcd den //= gcd print(num, den)