#include "bits/stdc++.h" using namespace std; #define ll long long int #define rep(i,n) for( int i = 0; i < n; i++ ) #define rrep(i,n) for( int i = n; i >= 0; i-- ) #define REP(i,s,t) for( int i = s; i <= t; i++ ) #define RREP(i,s,t) for( int i = s; i >= t; i-- ) #define dump(x) cerr << #x << " = " << (x) << endl; #define INF 2000000000 #define mod 1000000007 #define INF2 1000000000000000000 #define int long long signed main(void) { cin.tie(0); ios::sync_with_stdio(false); int n1; cin >> n1; int A[10]; rep(i, n1) cin >> A[i]; int n2; cin >> n2; int B[10]; rep(i, n2) cin >> B[i]; int up = 1; int down = 1; up *= A[0]; down *= B[0]; for(int i = 1; i < n1; i++) down *= A[i]; for(int i = 1; i < n2; i += 2) up *= B[i]; for(int i = 0; i < n2; i += 2) down *= B[i]; REP(i, 2, 1000000) { while (up % i == 0 && down % i == 0) { up /= i; down /= i; } } if (down < 0) { down *= -1; up *= -1; } cout << up << " " << down << endl; return 0; }