using System; using System.Linq; public class P0296 { public static void Main() { var nhmt = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToList(); const int oneday = 1440; var n = (nhmt[0] - 1) % oneday; var h = nhmt[1]; var m = nhmt[2]; var t = nhmt[3]; var result = (n * t + h*60 + m) % oneday; Console.WriteLine(result / 60); Console.WriteLine(result % 60); } }