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(); long[] A = new long[n1]; for (int i = 0; i < n1; ++i) A[i] = sc.nextLong(); int n2 = sc.nextInt(); long[] B = new long[n2]; for (int i = 0; i < n2; ++i) B[i] = sc.nextLong(); 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)); } }