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

kishou = a[0] * 60 + a[1]

shuusin = a[2] * 60 + a[3]

print((shuusin - kishou - a[4]))
a = list(map(int, input().split()))

b = (a[2] * 60 + a[3]) - (a[0] * 60 + a[1])

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

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

-kishou = a[0] * 60 + a[1] -shuusin = a[2] * 60 + a[3] -print((shuusin - kishou - a[4])) +b = (a[2] * 60 + a[3]) - (a[0] * 60 + a[1]) +print((b - a[4]))