use std::io::{Read,stdin}; fn main() { let mut buf = String::new(); stdin().read_to_string(&mut buf).unwrap(); let mut tok = buf.split_whitespace(); let mut get = || tok.next().unwrap(); macro_rules! get { ($t:ty) => (get().parse::<$t>().unwrap()); () => (get!(i64)); } let n = get!(); let mut x1 = 1; let mut x2 = 1; for i in 0..n { let x = get!(); if i == 0 { x1 *= x; } else { x2 *= x; } } let m = get!(); let mut ys = vec![]; for _ in 0..m { let y = get!(); ys.push(y); } ys.reverse(); let mut y1 = 1; let mut y2 = 1; for i in 0..ys.len() { if i % 2 == 0 { y1 *= ys[i]; } else { y2 *= ys[i]; } } if m % 2 == 0 { x1 *= y1; x2 *= y2; } else { x1 *= y2; x2 *= y1; } let g = gcd(x1, x2); let s = x1.signum() * x2.signum(); let x1 = x1.abs() * s / g; let x2 = x2.abs() / g; println!("{} {}", x1, x2); } fn gcd(a: i64, b: i64) -> i64 { fn _gcd(a: i64, b: i64) -> i64 { if a == 0 { b } else { _gcd(b % a, a) } } let a = a.abs(); let b = b.abs(); if a < b { _gcd(a, b) } else { _gcd(b, a) } }