open System [] let main args = let IN = Console.ReadLine().Split(' ') let N, H, M, T = Int32.Parse(IN.[0]), Int32.Parse(IN.[1]), Int32.Parse(IN.[2]), Int32.Parse(IN.[3]) let M = ((M + H * 60) + T * (N - 1)) let H = (M / 60) % 24 let M = (M % 60) % 60 printfn "%d\n%d" H M 0