let () = Scanf.scanf "%d %d %d %d\n" @@ fun n h m t -> let p = t * (n-1) + m in let ph, pm = p / 60, p mod 60 in Printf.printf "%d\n%d\n" (h+ph) pm