#include #define rep(i,a,b) for(int i=int(a);i> N; ll a1 = 1, b1 = 1; cin >> a1; rep(i,1,N){ int a; cin >> a; b1 *= a; } cin >> N; ll a2 = 1, b2 = 1; rep(i,0,N){ int a; cin >> a; if(i % 2 == 0)a2 *= a; else b2 *= a; } //cout << a1 << " " << b1 << endl; //cout << a2 << " " << b2 << endl; a1 *= b2; a2 *= b1; ll g = gcd(a1, a2); cout << (a1 / g) << " " << (a2 / g) << endl; }