use std::io::Read; fn main() { let mut buf = String::new(); std::io::stdin().read_to_string(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); let n: usize = iter.next().unwrap().parse().unwrap(); let h: usize = iter.next().unwrap().parse().unwrap(); let m: usize = iter.next().unwrap().parse().unwrap(); let t: usize = iter.next().unwrap().parse().unwrap(); let elapsed_minutes: usize = t * (n-1); println!("{h}\n{m}", h = (h + (m + elapsed_minutes)/60) % 24, m = (m + elapsed_minutes) % 60 ); }