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!(); for i in 0..m { let y = get!(); if i + 1 < m { x2 *= y; } else { x1 *= y; } } let g = gcd(x1, x2); let s = (x1 * 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) } }