n1=int(input()) a=list(map(int,input().split())) n2=int(input()) b=list(map(int,input().split())) up=1 down=1 def gcd(a, b): if(a%b==0): return b else: return gcd(b, a%b) for i in range(n1): if i==0: up*=a[i] else: down*=a[i] for i in range(n2): if i%2==0: down*=b[i] else: up*=b[i] if up<0 and down<0: up=-up down=-down d=gcd(up,down) up//=d down//=d print(str(up)+" "+str(down))