H, M = map(int, input().split())
T = int(input())
total = H*60+M+T
if total > 24*60:
total-=24*60
print(total//60, total%60)
SCwgTSA9IG1hcChpbnQsIGlucHV0KCkuc3BsaXQoKSkKVCA9IGludChpbnB1dCgpKQp0b3RhbCA9IEgqNjArTStUCmlmIHRvdGFsID4gMjQqNjA6CiAgICB0b3RhbC09MjQqNjAKcHJpbnQodG90YWwvLzYwLCB0b3RhbCU2MCk=