using System; using System.Collections.Generic; using System.Linq; class Program { public void Solve() { int[] NHMT = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray(); long H = NHMT[1]; long M = NHMT[2]; long sleep = NHMT[3] * (NHMT[0] - 1); H = (H + (M + sleep) / 60) % 24; M = (M + sleep) % 60; Console.WriteLine(H); Console.WriteLine(M); } static void Main() { var solver = new Program(); solver.Solve(); } }