import strutils, sequtils var N, H, M, T: int (N, H, M, T) = stdin.readLine.split.map parseInt let m = (N - 1) * T + M + 60 * H H = m div 60 mod 24 M = m mod 60 echo H, "\r\n", M