#include #include long gcd(long x, long y) { long r; x = labs(x); y = labs(y); if (y > x) { r = x; x = y; y = r; } while (y > 0) { r = x % y; x = y; y = r; } return x; } int main(void) { long n1, n2, a, b, numerator, denominator = 1, i; scanf("%ld", &n1); for (i = 0; i < n1; i++) { scanf("%ld", &a); if (1 > i) numerator = a; else denominator *= a; } scanf("%ld", &n2); for (i = 0; i < n2; i++) { scanf("%ld", &b); if (i % 2) numerator *= b; else denominator *= b; } if (0 > denominator) { numerator = -numerator; denominator = -denominator; } printf("%ld %ld", numerator / gcd(numerator, denominator), denominator / gcd(numerator, denominator)); return 0; }