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(); sc.close(); 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++){ int h = 0; int m = 0; m += (n[3] % 60); n[2] += m; m =0; if(n[2] >= 60){ n[1]++; n[2] -= 60; } h += (n[3] / 60); n[1] += h; h = 0; while(n[1] >= 24){ n[1] -= 24; } } System.out.println(n[1]); System.out.println(n[2]); } }