import java.util.Scanner; /** * http://yukicoder.me/problems/822 */ public class YukiCoder296 { public static void main(String[] args) { run(args); } public static void run(String[] args) { // Scanner sc = new Scanner("2 7 30 5"); // Scanner sc = new Scanner("1 8 0 5"); // Scanner sc = new Scanner("7 8 0 5"); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int h = sc.nextInt(); int m = sc.nextInt(); int t = sc.nextInt(); int total = t * (n - 1); int min = (total + m) % 60; int hour = (((total + m) / 60) + h) % 24; System.out.println(hour); System.out.println(min); } public void test() { // 2 7 30 5 , 7 35 // System.out("") } }