#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define Ma_PI 3.141592653589793 #define eps 0.00000001 #define LONG_INF 3000000000000000000 #define GOLD 1.61803398874989484820458 #define MAX_MOD 1000000007 #define MOD 998244353 #define REP(i,n) for(long long i = 0;i < n;++i) #define seg_size 524288 double dot(complex a, complex b) { return a.real() * b.real() + a.imag() * b.imag(); } double gyaku_dot(complex a, complex b) { return a.real() * b.imag() - a.imag() * b.real(); } double leng(complex a) { return sqrt(a.real()*a.real() + a.imag()*a.imag()); } double angles(complex a, complex b) { double cosine = dot(a, b) / (leng(a) * leng(b)); double sine = gyaku_dot(a, b) / (leng(a) * leng(b)); double kaku = acos(cosine); if (sine <= 0) { kaku = 2 * Ma_PI - kaku; } return kaku; } vector convex_hull(vector> a) { vector ans; double now_minnest = a[0].real(); int now_itr = 0; REP(i, a.size()) { if (now_minnest > a[i].real()) { now_minnest = a[i].real(); now_itr = i; } } ans.push_back(now_itr); complex ba(0, 1); while (true) { int now_go = 0; double now_min = 0; int starter = ans[ans.size() - 1]; for (int i = 0; i < a.size();++i) { if (i != starter) { double goa = angles(ba, a[i] - a[starter]); if (goa > now_min) { now_min = goa; now_go = i; } } } if (now_go == ans[0]) break; ans.push_back(now_go); ba = complex(a[now_go] - a[starter]); } return ans; } long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a%b); } int main() { int n,m; cin >> n; vector input; REP(i, n) { long long a; cin >> a; input.push_back(a); } cin >> m; REP(i, m) { long long a; cin >> a; input.push_back(a); } for (int i = 1; i < n; ++i) { input[n] *= input[i]; } for (int i = n + 1; i < n + m; ++i) { input[0] *= input[i]; } long long geko = gcd(input[0],input[n]); if (input[n] < 0) { if (geko > 0) geko *= -1; } cout << input[0] / geko << " " << input[n] / geko << endl; return 0; }