using System; public class Program { public static void Main() { long[] n = Array.ConvertAll(Console.ReadLine().Split(' '), delegate(string value) { return long.Parse(value); }); long m = n[1]*60+n[2]; m += (n[0]-1)*n[3]; m %= 24*60; Console.WriteLine("{0}\n{1}", m/60, m%60); } }