#include "bits/stdc++.h" // {{{ using namespace std; #define eb emplace_back #define emp emplace #define fi first #define se second #define X first #define Y second #define outl(x) cout << (x) << '\n' #define rep(i,n) for(int i=0; i < (int)(n); ++i) #define ALL(x) begin(x), end(x) #define TMPLT(T,U) template #define ten(p) (int)(1e##p) #define FILL(a,val) memset((a), (val), sizeof(a)) #define FAST() ios::sync_with_stdio(false), cin.tie(nullptr) #ifdef DEBUG #define debug(...) fprintf(stderr, __VA_ARGS__) #define show(x) clog << #x << " \t= " << (x) << '\n' #define line() fputs("\n--------------------------------\n", stderr) #else #define debug(...) #define show(x) #define LN() #endif using ll = long long; using pii = pair; TMPLT(T,U) inline bool chmax(T &a, U b){return b>a ? a=b,1 : 0;} TMPLT(T,U) inline bool chmin(T &a, U b){return b gcd(T x, U y) { return (x> N >> tmp; a = pii(tmp, 1); rep(i, N-1) { int x; cin >> x; a.se *= x; } cin >> N >> tmp; b = pii(tmp, 1); rep(i, N-1) { int x; cin >> x; b.se *= x; } debug("a: %d %d\n", a.fi, a.se); debug("b: %d %d\n", b.fi, b.se); pii ans = pii(a.fi * b.se, a.se * b.fi); int g = gcd(ans.fi, ans.se); ans.fi /= g; ans.se /= g; if (ans.fi * ans.se < 0) { ans.fi = -1 * abs(ans.fi); ans.se = abs(ans.se); } if (ans.se != 1) { cout << ans.fi << ' ' << ans.se << endl; } else { outl(ans.fi); } return 0; } } // {{{ signed main(){cout << fixed << setprecision(9); ydk::_vim_is_god_(); return 0;} // }}}