import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n1 = sc.nextInt(); long child = sc.nextInt(); long mother = 1; for (int i = 1; i < n1; i++) { mother *= sc.nextInt(); } int n2 = sc.nextInt(); mother *= sc.nextInt(); for (int i = 1; i < n2; i++) { child *= sc.nextInt(); } boolean isPlus = true; if (child < 0) { isPlus = false; child *= -1; } if (mother < 0) { isPlus = !isPlus; mother *= -1; } long d = gcd(child, mother); child /= d; mother /= d; if (!isPlus) { child *= -1; } System.out.println(child + " " + mother); } static long gcd(long x, long y) { if (x % y == 0) { return y; } else { return gcd(y, x % y); } } }