package yuki_coder; import java.util.Scanner; public class No_296 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.nextLine(); String[] str = s.split(" ", 0); int[] n = new int[4]; for(int i = 0; i < 4; i++){ n[i] = Integer.parseInt(str[i]); } n[0]--; for(int i = 0; i < n[0]; i++){ if(n[2] >= 60){ if(n[1]>=24){ n[1] = 0; } n[1]++; n[2] += -60; } n[2] += n[3]; } System.out.println(n[1]); System.out.println(n[2]); } }