import math n=int(input()) a=list(map(int,input().split())) m=int(input()) b=list(map(int,input().split())) x,y=1,1 for i in range(1,len(a)): x*=a[i] for j in range(1,len(b)): y*=b[j] top=a[0]*y bottom=b[0]*x g=math.gcd(top,bottom) print(str(top//g)+' '+str(bottom//g))