/* -*- coding: utf-8 -*- * * 751.cc: No.751 Frac #2 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 10; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N], bs[MAX_N]; /* subroutines */ ll __gcd(ll m, ll n) { if (m < n) swap(m, n); while (n > 0) { ll r = m % n; m = n; n = r; } return m; } /* main */ int main() { int an; scanf("%d", &an); for (int i = 0; i < an; i++) scanf("%d", as + i); int bn; scanf("%d", &bn); for (int i = 0; i < bn; i++) scanf("%d", bs + i); ll anum = as[0]; ll aden = 1; for (int i = 1; i < an; i++) aden *= as[i]; ll bnum = 1, bden = 1; for (int i = bn - 1; i >= 0; i--) swap(bnum, bden), bnum *= bs[i]; ll num = anum * bden; ll den = aden * bnum; if (den < 0) num *= -1, den *= -1; ll g = __gcd(abs(num), den); num /= g, den /= g; printf("%lld %lld\n", num, den); return 0; }