s_h, s_m, e_h, e_m = list(map(int, input().split()))
if e_h > s_h or (e_h == s_h and e_m > s_m):
h_diff = e_h - s_h
else:
h_diff = (e_h - s_h) + 24
if e_m < s_m:
h_diff -= 1
m_diff = (e_m - s_m) + 60
else:
m_diff = e_m - s_m
print('O JOGO DUROU ',h_diff,' HORA(S) E ', m_diff,' MINUTO(S)', sep='',end='
')
s_h, s_m, e_h, e_m = list(map(int, input().split()))
if e_h > s_h or (e_h == s_h and e_m > s_m):
h_diff = e_h - s_h
else:
h_diff = (e_h - s_h) + 24
if e_m < s_m:
h_diff -= 1
m_diff = (e_m - s_m) + 60
else:
m_diff = e_m - s_m
print('O JOGO DUROU ',h_diff,' HORA(S) E ', m_diff,' MINUTO(S)', sep='',end='
')