package testJava; import java.util.*; public class Main { public static void main(String [] args){ try {(new Main()).run();} catch(Exception e){} } static Scanner cin; void run() { cin = new Scanner(System.in); int N = cin.nextInt(); int H = cin.nextInt(); int M = cin.nextInt(); int T = cin.nextInt(); M += (N-1) * T; H += M / 60; M %= 60; H %= 24; System.out.println(H); System.out.println(M); } }