#include using namespace std; int main() { long N, A = 1, B = 1; cin >> N; for (int i = 0, a; i < N && cin >> a; i++) ((i) ? B : A) *= a; cin >> N; for (int i = 0, b; cin >> b; i++) ((i) ? A : B) *= b; if (B < 0) A = -A, B = -B; long g = gcd(A, B); cout << A / g << " " << B / g << "\n"; }