import java.util.Scanner; public class No296 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int[] x = new int[4]; for (int i = 0 ; i< x.length ; i++) x[i] = sc.nextInt(); x[2] = x[2] + ((x[0] - 1) * x[3]); x[1] = (x[2] / 60) + x[1]; x[1] %= 24; x[2] %= 60; System.out.println(x[1]); System.out.println(x[2]); sc.close(); } }