#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define llong long long llong gcd(llong a, llong b) { if(a % b == 0) return b; return gcd(b, a % b); } int main() { int n1, n2; llong a = 1; llong b = 1; cin >> n1; rep(i, n1) { int val; cin >> val; if(i == 0) a *= val; else b *= val; } cin >> n2; rep(i, n2) { int val; cin >> val; if(i % 2 == 0) b *= val; else a *= val; } bool flg = a / abs(a) * b < 0; a = abs(a); b = abs(b); llong gcdval = gcd(max(a, b), min(a, b)); if(flg) a *= -1; cout << a / gcdval << " " << b / gcdval << "\n"; }