#include // #include using namespace std; // using namespace atcoder; 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 rall(x) (x).rbegin(), (x).rend() #define sz(x) ((ll)(x).size()) #define len(x) ((ll)(x).length()) #define endl "\n" template void chmax(T &a, const T b){ a = max(a, b); } template void chmin(T &a, const T b){ a = min(a, b); } int main() { cin.tie(0); ios::sync_with_stdio(false); // ifstream in("input.txt"); // cin.rdbuf(in.rdbuf()); ll n1; cin >> n1; vector a(n1); rep(i, n1) cin >> a[i]; ll n2; cin >> n2; vector b(n2); rep(i, n2) cin >> b[i]; ll bs = a[0], bb = 1; rep(i, n2) { if (i % 2 == 0) { bb *= b[i]; } else { bs *= b[i]; } } reps(i, 1, n1) { bb *= a[i]; } ll gcd = __gcd(abs(bb), abs(bs)); bb /= gcd; bs /= gcd; if ((bb < 0) && (bs < 0)) { bb *= -1; bs *= -1; } else if (bb < 0) { bb *= -1; bs *= -1; } printf("%lld %lld\n", bs, bb); return 0; }