#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a%b); } // override function template of std::gcd long long gcd(int a, int b) { return gcd((long long)a, (long long)b); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n1; cin >> n1; vector a(n1); REP (i, n1) cin >> a[i]; int n2; cin >> n2; vector b(n2); REP (i, n2) cin >> b[i]; long long p = a[0], q = 1; for (int i = 1; i < n1; i++) q *= a[i]; for (int i = 0; i < n2; i++) { if (i % 2 == 0) q *= b[i]; else p *= b[i]; } long long g = gcd(abs(p), abs(q)); p /= g; q /= g; p *= q / abs(q); q = abs(q); cout << p << " " << q << endl; return 0; }