use proconio::input; fn main(){ input!{ n:usize, h:usize,mut m:usize,t:usize, } m+=h*60;m+=t*(n-1);m%=24*60; print!("{}\n{}",m/60,m%60); }