#include using namespace std; long long gcd (long long a, long long b) { if (a < b) { swap(a, b); } if (b == 0) { return 0; } while (b) { a %= b; swap(a, b); } if (a < 0) { a *= -1; } return a; } pair reduce (pair a, pair b) { long long num = a.first * b.second; long long den = a.second * b.first; long long g = gcd(num, den); num /= g; den /= g; if (den < 0) { num *= -1; den *= -1; } return {num, den}; } int main() { ios::sync_with_stdio(false); cin.tie(0); int m; cin >> m; vector a(m); for (int i = 0; i < m; i++) { int tmp; cin >> tmp; a[i] = tmp; } pair frc; if (m ==1) { frc = {a[0], 1}; } else { frc = {a[0], a[1]}; } for (long long i = 2; i < m; i++) { frc = reduce(frc, {a[i], 1}); } int n; cin >> n; vector b(n); for (int i = 0; i < n; i++) { int tmp; cin >> tmp; b[i] = tmp; } pair grc; if (n == 1) { grc = {b[n - 1], 1}; } else { grc = {b[n - 2], b[n - 1]}; } for (int i = n - 3; i >= 0; i--) { grc = reduce({b[i], 1}, grc); } pair ans = reduce(frc, grc); cout << ans.first << ' ' << ans.second << '\n'; return 0; }