A = list(map(int, input().split()))



h = (A[2]-A[0])*60+A[3]-A[1]-A[4]

print(h)
A = list(map(int, input().split()))



print(((A[2]*60+A[3])-(A[0]*60+A[1])-A[4]))
A = list(map(int, input().split()))
h = (A[2] - A[0]) * 60 + A[3] - A[1] - A[4]
print(h)

A = list(map(int, input().split()))
print(((A[2] * 60 + A[3]) - (A[0] * 60 + A[1]) - A[4]))

-h = (A[2] - A[0]) * 60 + A[3] - A[1] - A[4] -print(h) +print(((A[2] * 60 + A[3]) - (A[0] * 60 + A[1]) - A[4]))