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