import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int H = sc.nextInt(); int M = sc.nextInt(); int T = sc.nextInt(); M += (N - 1) * T; for(;;) { if(M < 60) { break; }else { H++; M -= 60; if(H > 23) { H = 0; } } } sc.close(); System.out.println(H); System.out.println(M); } }