import strutils, sequtils var vals = stdin.readline.split.map(parseInt) n = vals[0] h = vals[1] m = vals[2] t = vals[3] m += t * (n-1) h += m div 60 m = m mod 60 h = h mod 24 echo h echo m