#include using namespace std; using ll = long long; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout<<(s)<> N1; ll child = 1; ll mother = 1; FOR(i, 0, N1){ ll a; cin >> a; if(i==0){ child *= a; }else{ mother *= a; } } ll N2; cin >> N2; FOR(i, 0, N2){ ll b; cin >> b; if(i%2==1){ child *= b; }else{ mother *= b; } } bool is_minus = false; if(child * mother < 0){ is_minus = true; } child = abs(child); mother = abs(mother); ll g = gcd(child, mother); child /= g; mother /= g; if(is_minus){ cout << '-'; } cout << child << ' ' << mother << endl; return 0; }