fn read_vec() -> Vec { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } fn main() { let pqr:Vec = read_vec(); let abc:Vec = read_vec(); let lefts = vec![ pqr[0]*(abc[0]-1)+1, pqr[1]*(abc[0]+abc[1]-1)+1, pqr[2]*(abc[0]+abc[1]+abc[2]-1)+1 ]; let rights = vec![ pqr[0]*abc[0], pqr[1]*(abc[0]+abc[1]), pqr[2]*(abc[0]+abc[1]+abc[2]), ]; let left:&i64 = lefts.iter().max().unwrap(); let right:&i64 = rights.iter().min().unwrap(); if left > right { println!("-1"); } else { println!("{} {}", left, right); } }