import java.util.Scanner; public class No296 { 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(); int sum = H * 60 + M; // 目覚ましの時間を分に換算 sum += T * (N - 1); //起床時間(単位:分) System.out.println((sum / 60) % 24); System.out.println(sum % 60); } }