#!/usr/bin/python3 def to_seconds(line): seconds = 0 for part in line.split(':'): seconds *= 60 seconds += int(part) return seconds n = int(input()) prev_time = 0 for i in range(n): time = to_seconds(input()) print(time - prev_time) prev_time = time