#coding: UTF-8 import sys from math import pi from collections import deque from functools import reduce ### defs ### ### main ### N = int(sys.stdin.readline()) HMhm = map(lambda s:s.split(), map(lambda s:s.strip('\r\n'),sys.stdin.readlines())) HMhm = map(lambda lst: list(map(lambda s:s.split(':'),lst)) , HMhm) HMhm = map(lambda lst: list(map(lambda tm:int(tm[0])*60+int(tm[1]),lst)) , HMhm) HMhm = map(lambda lst: [lst[0],lst[1]+60*24] if lst[1]