use std::io::{self, BufReader, BufWriter, Read, Write}; fn main() { let stdin = io::stdin(); let mut stdin = BufReader::new(stdin.lock()); let stdout = io::stdout(); let mut stdout = BufWriter::new(stdout.lock()); let mut buf = String::new(); stdin.read_to_string(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); let n: u32 = iter.next().unwrap().parse().unwrap(); let mut h: u32 = iter.next().unwrap().parse().unwrap(); let mut m: u32 = iter.next().unwrap().parse().unwrap(); let t: u32 = iter.next().unwrap().parse().unwrap(); let x = (n - 1) * t; m += x; h += m / 60; m %= 60; h %= 24; writeln!(&mut stdout, "{}\n{}", h, m).unwrap(); }