#include using namespace std; using int64 = long long; int main() { int N, M; int64 latte = 1, malta = 1; int f = 1; cin >> N; for(int i = 0; i < N; i++) { int x; cin >> x; f *= x; if(i == 0) latte *= x; else malta *= x; } cin >> M; for(int i = 0; i < M; i++) { int x; cin >> x; f *= x; if((M - i) % 2 == 0) malta *= x; else latte *= x; } latte = abs(latte); malta = abs(malta); auto p = __gcd(latte, malta); latte /= p; malta /= p; if(f < 0) latte *= -1; cout << latte << " " << malta << endl; }