#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef std::pair pii; typedef std::pair pli; typedef std::pair pll; #define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i) #define REP(i,n) FOR(i,n,0) #define IREP(i,n) for(ll i=(ll)(n);i>=0;--i) #define OF64 std::setprecision(10) const ll MOD = 1000000007; const ll INF = (ll)1e15; ll A[20], B[20]; ll gcd(ll a, ll b) { if (a < b) { swap(a, b); } ll c = a%b; if (c == 0)return b; return gcd(b, c); } int main() { int n; cin >> n; REP(i, n) { cin >> A[i]; } int m; cin >> m; REP(i, m) { cin >> B[i]; } ll oa = A[0], ea = 1; REP(i, n - 1) { ea *= A[1 + i]; } ll ob = 1, eb = 1; REP(i, m) { if (i % 2 == 0) { eb *= B[i]; } else { ob *= B[i]; } } ll x = ob*oa, y = eb*ea; ll sign = (x / abs(x)) * (y / abs(y)); ll k = gcd(abs(x), abs(y)); cout << sign*(abs(x) / k) << " " << abs(y) / k << endl; return 0; }