import java.util.Scanner; class Main { public static long gcd(long x, long y) { long r; x = Math.abs(x); y = Math.abs(y); if (y > x) { r = x; x = y; y = r; } while (y > 0) { r = x % y; x = y; y = r; } return x; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); long n1, n2, a, b, numerator = 0, denominator = 1, i; n1 = sc.nextInt(); for (i = 0; i < n1; i++) { a = sc.nextInt(); if (1 > i) numerator = a; else denominator *= a; } n2 = sc.nextInt(); for (i = 0; i < n2; i++) { b = sc.nextInt(); if (i % 2 == 1) numerator *= b; else denominator *= b; } sc.close(); if (0 > denominator) { numerator = -numerator; denominator = -denominator; } System.out.print(numerator / gcd(numerator, denominator) + " " + denominator / gcd(numerator, denominator)); } }