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) top//=g;bottom//=g if top>0 and bottom<0: top*=-1;bottom*=-1 print(str(top)+' '+str(bottom))