import java.io.*; import java.util.Scanner; public class Main_yukicoder751 { private static Scanner sc; private static Printer pr; private static void solve() { int n1 = sc.nextInt(); int[] a = new int[n1]; for (int i = 0; i < n1; i++) { a[i] = sc.nextInt(); } int n2 = sc.nextInt(); int[] b = new int[n2]; for (int i = 0; i < n2; i++) { b[i] = sc.nextInt(); } long nu = a[0]; long de = 1; for (int i = 1; i < n1; i++) { de *= a[i]; } long nub = b[n2 - 1]; long deb = 1; for (int i = n2 - 2; i >= 0; i--) { long tmp = deb; deb = nub; nub = b[i] * tmp; } long nuans = nu / gcd(nu, de); long deans = de / gcd(nu, de); nuans *= deb / gcd(nub, deb); deans *= nub / gcd(nub, deb); if (nuans < 0 && deans < 0) { nuans = -nuans; deans = -deans; } else if (nuans > 0 && deans < 0) { nuans = -nuans; deans = -deans; } pr.printf("%d %d%n", nuans, deans); } static long gcd(long n, long m) { if (m == 0) { return n; } else { return gcd(m, n % m); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } static class Printer extends PrintWriter { Printer(OutputStream out) { super(out); } } }