import java.util.*; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int hour=sc.nextInt(); int min=sc.nextInt(); int alarm=sc.nextInt(); int plus_min=alarm*(n-1); min+=plus_min; int plus_hour=min/60; min=min%60; hour+=plus_hour; hour=hour%24; System.out.println(hour); System.out.println(min); } }