#define _USE_MATH_DEFINES #include using namespace std; #define int long long int gcd(int x, int y) { return x ? gcd(y % x, x) : y; } signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int num = 1, den = 1; for (int i = 0; i < n; i++) { int x; cin >> x; if (i == 0) num *= x; else den *= x; } int m; cin >> m; for (int i = 0; i < m; i++) { int x; cin >> x; if (i % 2 == 0) den *= x; else num *= x; } int a = num / gcd(num, den); int b = den / gcd(num, den); if (b < 0) { b *= -1; a *= -1; } cout << a << " " << b << endl; return 0; }