package m.shin; import java.util.Scanner; public class Con296 { public static void main(String[] args) { // TODO 自動生成されたメソッド・スタブ Scanner s = new Scanner(System.in); int N = s.nextInt() , H = s.nextInt() , M = s.nextInt() , T = s.nextInt(); s.close(); H = (H + (T*(N-1)) /60) % 24; if((M = M + (T*(N-1)) %60) > 59){ H = (H + 1) % 24; } M = M % 60; System.out.println(H + "\n" + M); } }