#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; typedef pair pii; int main() { ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0; //cout << LONG_MAX << endl; //long long n, A[1000000000]; //ll n, m, q; ll x[100] = {}; ll y[100] = {}; c = 1; d = 1; cin >> a; for (int i = 0; i < a; i++) { cin >> x[i]; if (i == 0) { c *= x[i]; } else { d *= x[i]; } } cin >> b; for (int i = 0; i < b; i++) { cin >> y[i]; if (i %= 0) { d *= y[i]; } else { c *= y[i]; } } e = 1; if (c<0) { e = -1; c *= -1; } f = 1; if (d<0) { f = -1; d *= -1; } for (ll i = 2; i < 11; i++) { while (abs(c) % i == 0 && abs(d) % i == 0) { c /= i; d /= i; } } c *= e; d *= f; if (d<0) { c *= -1; d *= -1; } cout << c; cout << " "; cout << d << endl; ////std::cout << std::fixed; //cout << std::setprecision(20) << << endl; //cout << d+1 << endl; //cout << "" << endl; return 0; } //accumulate(x, x + a, 0); //memcpy(x, visited, sizeof(ll)*n); //void kansuu(ll num, ll visited[10]) {} //kansuu(1, zz); //cout << setprecision(15) << v << endl; //int temp; //for (int i = 0; i < n - 1; i++) { // for (int j = n - 1; j > i; j--) { // if (w[j - 1] < w[j]) { /* 前の要素の方が大きかったら */ // temp = w[j]; /* 交換する */ // w[j] = w[j - 1]; // w[j - 1] = temp; // } // } //}