#! /usr/bin/env python3 import math input() *a, = map(int, input().split()) input() *b, = map(int, input().split()) x = y = 1 for i in a[1:]+b[::2] : y *= i for i in a[:1]+b[1::2] : x *= i if y < 0 : y*=-1;x*=-1 t = math.gcd(x, y) print(x//t, y//t)