#include using namespace std; typedef long long ll; #define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--) #define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--) #define all(x) (x).begin(), (x).end() #define sz(x) ((ll)(x).size()) #define len(x) ((ll)(x).length()) vector> factorize(ll n) { vector> res; for (ll i = 2; (i * i) <= n; i++) { if (n % i) continue; res.emplace_back(i, 0); while((n % i) == 0) { n /= i; res.back().second++; } } if (n != 1) res.emplace_back(n, 1); return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); // ifstream in("input.txt"); // cin.rdbuf(in.rdbuf()); ll bsn, bs, bbn, bb, bbm = 1; cin >> bsn >> bs; rep(i, bsn - 1) { ll v; cin >> v; bbm *= v; } cin >> bbn >> bb; rep(i, bbn - 1) { ll v; cin >> v; bs *= v; } bb *= bbm; ll sub = __gcd(bs, bb); bs /= sub; bb /= sub; printf("%lld %lld\n", bs, bb); return 0; }