#include #include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() #define ll long long #define INF 1000000000000000000 typedef pair pll; long long GCD(long long a, long long b) { if (b == 0) return a; else return GCD(b, a % b); } int main() { cin.tie(0); ios::sync_with_stdio(false); int upp_bunshi = 0, upp_bunbo = 1, upp_bunshi_togo = 1, upp_bunbo_togo = 1; int low_bunshi = 0, low_bunbo = 1, low_bunshi_togo = 1, low_bunbo_togo = 1; int n1; cin >> n1; rep(i, n1) { int a; cin >> a; if (i == 0) { upp_bunshi = a; if (a < 0) upp_bunshi_togo = -1; } else upp_bunbo *= a; if (a < 0) upp_bunbo_togo *= -1; } int n2; cin >> n2; rep(i, n2) { int a; cin >> a; if (i == 0) { low_bunshi = a; if (a < 0) low_bunshi_togo = -1; } else low_bunbo *= a; if (a < 0) low_bunbo_togo *= -1; } int ans_bunshi = upp_bunshi_togo * low_bunbo_togo * abs(upp_bunshi) * abs(low_bunbo), ans_bunbo = upp_bunbo_togo * low_bunshi_togo * abs(upp_bunbo) * abs(low_bunshi); int gcd = GCD(abs(ans_bunbo), abs(ans_bunshi)); ans_bunbo /= gcd, ans_bunshi /= gcd; cout << ans_bunshi << " " << ans_bunbo << endl; }