#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; int A[20], B[20]; int gcd(int a, int b) { if (a < b) { swap(a, b); } int 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]; } int x = A[0], y = B[0]; REP(i, m - 1) { x *= B[1 + i]; } REP(i, n - 1) { y *= A[1 + i]; } //REP(i, max(n, m) - 1) //{ // int a = i < n - 1 ? A[i] : 1; // int b = i < m - 1 ? B[i] : 1; // int k = a*b / gcd(abs(a), abs(b)); // x *= k / a; y *= k / b; //} int sign = x*y / abs(x*y); int k = gcd(abs(x), abs(y)); cout << sign*abs(x) / k << " " << abs(y) / k << endl; return 0; }