# a,b,c=map(int,input().split())
# n=int(input())
# i=n//60
# l=n%60
# if c+l>=60:
# b=b+i+(c+l)//60
# c=(c+l)%60
# if b + i >= 60:
# a = a + 1
# b = (b + i) % 60
# c = c + l
# elif a<=24 and b<=59 and c<=59:
# b=b+i
# c=c+l
# else:
# a=0
# b=0
# c=0
# print(a,b,c)
# a, b = map(int, input().split())
# c = int(input())
#
# print(a+(b+c)//60,(b+c)%60)
# a,b=map(int,input().split())
# n=int(input())
# m=(b+n)//60
# a=(a+m)%24
# t = (b+n)%60
# b=b+t
# print(a,t)
a,b,c=map(int,input().split())
n=int(input())
t = (c+n)%60 # c+n이 몇 초인지?
l=(c+n)//60 # c+n이 몇 분인지?
m=(b+l)%60
h=a+(b+l)//60
print(h%24,m,t)