package yukiCoder; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class No00296 { public static void main(String[] args) { BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); String[] input = new String[4]; try { input = bufferedReader.readLine().split(" "); int n = Integer.parseInt(input[0]); int hour = Integer.parseInt(input[1]); int minute = Integer.parseInt(input[2]); int repeat = Integer.parseInt(input[3]); for (int i = 1 ; i < n ; i++) { minute += repeat; if (minute > 60) { hour += minute/60; minute %= 60; } if (hour > 24) hour %= 24; } if (hour == 24) hour = 0; System.out.println(hour); System.out.println(minute); } catch (IOException e) { e.printStackTrace(); } } }