#!/usr/bin/python2 # -*- coding: utf-8 -*- # † from operator import mul from fractions import Fraction as frac n = int(raw_input()) a = map(int, raw_input().split()) m = int(raw_input()) b = map(int, raw_input().split()) nume = [a[0]] + b[1::2] deno = a[1:] + b[0::2] nume = reduce(mul, nume) deno = reduce(mul, deno) res = frac(nume, deno) print res.numerator, res.denominator