from fractions import gcd def main(): n = int(input()) a = list(map(int, input().split())) m = int(input()) b = list(map(int, input().split())) ue = a[0] ue2 = 1 for i in range(1, n): ue2 *= a[i] shita = 1 shita2 = 1 for i in range(m): if i % 2 == 0: shita *= b[i] else: shita2 *= b[i] ue *= shita2 shita *= ue2 g = gcd(ue, shita) print(ue//g, shita//g) if __name__ == '__main__': main()