import java.util.Scanner; class Yuki{ int againDream; void setAgainDream(int i){ this.againDream = i; } } public class No_296 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Yuki yuki = new Yuki(); yuki.setAgainDream(sc.nextInt()); int hour = sc.nextInt(); int minute = sc.nextInt(); int interval = sc.nextInt(); minute += (yuki.againDream-1)*interval; hour += minute/60; minute %= 60; hour %= 24; System.out.println(hour); System.out.println(minute); sc.close(); } }