import java.util.Calendar; import java.util.Date; import java.util.Scanner; public class Main { public static void main(String args[]){ Scanner input = new Scanner(System.in); int sleeptimes = input.nextInt(); int hour = input.nextInt(); int minute = input.nextInt(); int interval = input.nextInt(); minute += interval * (sleeptimes-1); Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, hour); c.set(Calendar.MINUTE,minute); Date waketime = c.getTime(); c.setTime(waketime); int wakehour = c.get(Calendar.HOUR_OF_DAY); int wakeminute = c.get(Calendar.MINUTE); System.out.println(wakehour); System.out.println(wakeminute); } }