import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n1 = sc.nextInt(); if (!(1 <= n1 && n1 <= 10)) throw new AssertionError(); long[] A = new long[n1]; for (int i = 0; i < n1; ++i) { A[i] = sc.nextLong(); if (!(1 <= Math.abs(A[i]) && Math.abs(A[i]) <= 10)) throw new AssertionError(); } int n2 = sc.nextInt(); if (!(1 <= n2 && n2 <= 10)) throw new AssertionError(); long[] B = new long[n2]; for (int i = 0; i < n2; ++i) { B[i] = sc.nextLong(); if (!(1 <= Math.abs(B[i]) && Math.abs(B[i]) <= 10)) throw new AssertionError(); } long den = 1; long num = 1; for (int i = n2 - 1; i >= 0; i -= 2) { if (n2 % 2 == 1) { den = den * B[i]; } else { num = num * B[i]; } } for (int i = n2 - 2; i >= 0; i -= 2) { if (n2 % 2 == 0) { den = den * B[i]; } else { num = num * B[i]; } } for (int i = 1; i < n1; ++i) { den = den * A[i]; } num *= A[0]; long g = gcd(Math.abs(den), Math.abs(num)); den /= g; num /= g; System.out.println((int) (Math.signum(num) * Math.signum(den)) * Math.abs(num) + " " + Math.abs(den)); } static long gcd(long a, long b) { if (a > b) return gcd(b, a); if (a == 0) return b; return gcd(b % a, a); } public static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }