from math import gcd n_1=int(input()) a=list(map(int,input().split())) n_2=int(input()) b=list(map(int,input().split())) x=y=1 for i in a[1:]+b[::2]: y*=i for j in a[:1]+b[1::2]: x*=i if y<0: y=-y;x=-x d=gcd(x,y) print(x//d,y//d)