using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace lecture { class Program { public static void Main(String[] args) { int[] line = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray(); int N = line[0]; int H = line[1]; int M = line[2]; int Y = line[3]; int byou = 0; int X; int Z = 0; N = N - 1; byou = N * Y; M = M + byou; for (X = 0; M > 60; X++) { H = H + X; } if (H >= 24) { Z = H / 24; H = 0 + Z - 1; } M = M - 60 * X; Console.WriteLine(H); Console.WriteLine(M); } } }