#P1425
##题解
s = input().split()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
#total_time = (c*60+d) - (a*60+b)
hour = c-a
minu = d-b
if(minu < 0):
hour -= 1
minu += 60
print(hour,minu)
#P1425
##题解
s = input().split()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
#total_time = (c*60+d) - (a*60+b)
hour = c-a
minu = d-b
if(minu < 0):
hour -= 1
minu += 60
print(hour,minu)