import sequtils, strutils var n, h, m, t: int (n, h, m, t) = stdin.readLine.split.map parseInt let mo = m + (n - 1) * t let ans_t = mo mod 60 let ho = h + (mo div 60) let ans_h = ho mod 24 echo ans_h echo ans_t