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