function Main(input) { // let data = input.split("\n"); let data = input.split(" "); let N = Number(data[0]); let H = Number(data[1]); let M = Number(data[2]); let T = Number(data[3]); let delayM = (N-1)*T; let afterTime = delayM + M; if (afterTime<60) { M = afterTime; } else { H = Math.floor(afterTime/60) + H; M = afterTime%60 + M; } if (H>=24) { H = H%24; } console.log(H + "\n" + M); } Main(require("fs").readFileSync("/dev/stdin", "utf8"));