'''
n
16.0 24.0 7.0 (x) 4.0
16.5 21.5 4.0
17.5 21.5 3.0
19.5 24.0 3.5
22.5 24.0 0.5
15
'''
# list=[]
# tot=0
# n=0
# for i in range(5):
# a, b = map(float, input().split())
# n=b-a-1
# if n>0 and 4>=n:
# list.append(n)
# elif 4<n:
# n=4
# list.append(n)
# tot = sum(list)
# if tot>=15:
# tot=tot*9500
# elif tot<=5:
# tot=tot*10500
# else:
# tot=tot*10000
# print(int(tot))
# tot=0
# a,b,c,d,e=map(int,input().split())
# tot=(a*a+b*b+c*c+d*d+e*e)%10
# print(tot)
# a=int(input())
# b=int(input())
# tot=0
# list=[]
# for i in range(a,b+1): # i : 소수 후보들
# #i가 소수인지? -> i의 약수가 두개 인지?
# cnt=0
# for j in range(1,i+1):
# if i%j==0:
# cnt+=1
# if cnt==2 :
# list.append(i)
#
# print(sum(list))
# print(list[0])
a,b,c=map(int,input().split())
n=int(input())
a={a+(n//60)}//60
b=(b+n)//60
c=(c+n)%60
print(a,b,c)



