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 += 1; minute -= 60; } } System.out.println(hour); System.out.println(minute); } catch (IOException e) { e.printStackTrace(); } } }