import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args)throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); String[] str = line.split(" "); int n=Integer.parseInt(str[0]),h=Integer.parseInt(str[1]),m=Integer.parseInt(str[2]),t=Integer.parseInt(str[3]); while(n>1){ n--; m+=t; if(m>=60){ m-=60; h++; } if(h>=24){ h-=24; } } System.out.println(h); System.out.println(m); } }