def findAnswer(A, B, C, D):
S = D % 60 + C
D = D // 60
M = D % 60 + B
D = D // 60
H = D % 24 + A
#print(H, M, S)
if S >= 60:
M += 1
S -= 60
if M >= 60:
H += 1
M -= 60
if H >= 24:
H -= 24
#끝 시, 끝 분, 끝 초 필요
print(H, M, S)
return
A, B, C = map(int, input().split())
D = int(input())
findAnswer(A, B, C, D)
파이썬은 끔찍하다