import java.io.PrintWriter; import java.util.Scanner; class Main { public static long gcd(long a, long b) { return b != 0 ? gcd(b, a % b) : Math.abs(a); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); long A = sc.nextLong(), B = 1, tmp; for (int i = 1; i < n; ++i) B *= sc.nextLong(); n = sc.nextInt(); for (int i = 0; i < n; ++i) { if (i % 2 == 0) B *= sc.nextLong(); else A *= sc.nextLong(); } sc.close(); if (B < 0) { A = -A; B = -B; } tmp = gcd(A, B); pw.print(A / tmp + " " + B / tmp); pw.close(); } }