INF = 10 ** 9 MOD = 10 **9 + 7 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from math import gcd def main(): n = int(input()) a = list(map(int,input().split())) m = int(input()) b = list(map(int,input().split())) child = a[0] mother = 1 for i in range(1,n): mother *= a[i] for i in range(m): if i%2 == 0: mother *= b[i] else: child *= b[i] if child < 0 and mother < 0: child *= -1 mother *= -1 elif child > 0 and mother < 0: child *= -1 mother *= -1 g = gcd(child,mother) print(child//g,mother//g) if __name__=='__main__': main()