#include #include #include #include #include #include #include #include #include using namespace std; using ll=long long; using ld=long double; using P=pair; #define MOD 1000000007LL #define INF 1000000000LL #define EPS 1e-10 #define FOR(i,n,m) for(ll i=n;i<(ll)m;i++) #define REP(i,n) FOR(i,0,n) #define DUMP(a) REP(d,a.size()){cout<> n1; vector a(n1); REP(i,n1) cin >> a[i]; if(n1 == 1) { n1++; a.pb(a[0]); a[0] = 1; } ll n2; cin >> n2; vector b(n2); REP(i,n2) cin >> b[i]; if(n2 == 1) { n2++; b.pb(1); } reverse(ALL(a)); while(n1 > 2) { a[n1 - 3] = a[n1 - 3] * a[n1 - 2]; a[n1 - 2] = a[n1 - 1]; n1--; } while(n2 > 2) { b[n2 - 3] = b[n2 - 3] * b[n2 - 1]; n2--; } ll up = a[1] * b[1], dw = a[0] * b[0]; if(dw < 0 && up < 0) { dw = abs(dw); up = abs(up); } else if (dw < 0) { dw = abs(dw); up = -up; } ll g = gcd(up, dw); cout << up / g << " " << dw / g << endl; return 0; }