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 overTime = t*(n-1); h+=overTime/60; h%=24; m+=overTime; m%=60; System.out.println(h); System.out.println(m); } }