h,m,s=map(int,input().split())
s2=int(input())
x=s+s2
if(x>=60):
m+=x//60
x%=60
if(m>=60):
h+=m//60
m%=60
if(h>=24):
h-=24
print(h,m,x)
aCxtLHM9bWFwKGludCxpbnB1dCgpLnNwbGl0KCkpCgpzMj1pbnQoaW5wdXQoKSkKCng9cytzMgoKaWYoeD49NjApOgoKICAgIG0rPXgvLzYwCgogICAgeCU9NjAKCmlmKG0+PTYwKToKCiAgICBoKz1tLy82MAoKICAgIG0lPTYwCgppZihoPj0yNCk6CgogICAgaC09MjQKCnByaW50KGgsbSx4KQ==