#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 x = A[0], y = B[0]; REP(i, m - 1) { x *= B[1 + i]; } REP(i, n - 1) { y *= A[1 + i]; } 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; }