#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); long long nume = 1, denm = 1; int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; if (i == 0) nume *= x; else denm *= x; } cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x; if (i % 2 == 1) nume *= x; else denm *= x; } long long g = __gcd(abs(nume), abs(denm)); cout << nume / g << " " << denm / g << endl; return 0; }