#include using namespace std; long gcd(long x, long y) { return y ? gcd(y, x % y) : abs(x); } int main() { int n; long A, B = 1, tmp; cin >> n >> A; for (int i = 1; i < n; ++i) { cin >> tmp; B *= tmp; } cin >> n; for (int i = 0; i < n; ++i) { cin >> tmp; if (i % 2) A *= tmp; else B *= tmp; } if (B < 0) { A = -A; B = -B; } tmp = gcd(A, B); cout << A / tmp << " " << B / tmp; }