#include #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n) - 1; i >= 0; i--) #define reps(i, n) for (int i = 1; i <= (n); i++) #define all(a) (a).begin(), (a).end() #define bit(b) (1ull << (b)) using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; using f64 = double; using vi32 = vector; using vu32 = vector; using vi64 = vector; using vu64 = vector; using vf64 = vector; using vstr = vector; using vvi32 = vector; using vvu32 = vector; using vvi64 = vector; using vvu64 = vector; using vvf64 = vector; template bool amax(T &x, S y) { if (x < y) { x = y; return 1; } return 0; } template bool amin(T &x, S y) { if (y < x) { x = y; return 1; } return 0; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(16); int na, nb; cin >> na; vi64 a(na); rep(i, na) cin >> a[i]; cin >> nb; vi64 b(nb); rep(i, nb) cin >> b[i]; reps(i, nb - 1) a[0] *= b[i]; reps(i, na - 1) b[0] *= a[i]; i64 c = __gcd(a[0], b[0]); a[0] /= c; b[0] /= c; if (b[0] / abs(b[0]) == -1) { a[0] *= -1; b[0] *= -1; } cout << a[0] << " " << b[0] << endl; return 0; }