#include using namespace std; #define int long long #define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++) #define all(x) (x).begin(),(x).end() #define pb push_back templatebool chmax(T &a,T b){if(abool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;} typedef pair pii; typedef vector vi; typedef vector vvi; const int inf = 1LL<<60; const int mod = 1e9 + 7; const double eps = 1e-9; /*{ }*/ int gcd(int a, int b) { if(a < b) swap(a, b); if(b == 0) return a; return gcd(b, a%b); } signed main() { int na; cin >> na; vi a(na); rep(i, 0, na) cin >> a[i]; int nb; cin >> nb; vi b(nb); rep(i, 0, nb) cin >> b[i]; int n = a[0], m = b[0]; rep(i, 1, nb) n *= b[i]; rep(i, 1, na) m *= a[i]; int g = gcd(abs(n), abs(m)); if(m < 0) n *= -1, m *= -1; cout << n/g << " " << m/g << endl; return 0; }