now = input().split()
use = int(input())
h = int(now[0])
m = int(now[1])
m_plus = (m+use)%60
h_plus = (m+use)//60
if (h+h_plus)>=24 and m+m_plus>=60:
print(0+(h_plus-1), m_plus)
else:
print(h+h_plus, m_plus)
맞는줄 알았는데..ㅠㅠ
now = input().split()
use = int(input())
h = int(now[0])
m = int(now[1])
h += (use)//60
m += (use)%60
if m >= 60:
h += 1
m -= 60
if h >= 24:
h -= 24
print(h, m)
use(걸리는시간)을 60으로 먼저 나눴으면 되는데 더한다음에 나눈다는 생각에 사로잡혀서 경우의 수가 많아졌고 그걸 다 생각하느라 if문을 나누기가 힘들었다.