Kasi
At one of the Moscow train stations, there are N ticket counters, each following a fixed daily schedule without breaks.
Your task is to calculate the total duration of time during the day when all counters are open simultaneously.
Input
The first line contains an integer N (0 < N ≤ 1000), representing the number of ticket counters. Each of the next N lines contains 4 integers separated by spaces. The first two integers represent the opening time in hours and minutes (hours range from 0 to 23, and minutes range from 0 to 59). The last two integers represent the closing time in the same format.
The opening time indicates that the counter is operational from that minute, while the closing time indicates that the counter stops operating at that minute. For instance, if a counter is open from 10:30 to 18:30, it operates for 480 minutes each day. If the opening and closing times are the same, the counter operates 24 hours a day. If the opening time is later than the closing time, the counter operates overnight, starting before midnight and ending the next day.
Output
Output a single number representing the total number of minutes per day during which all N counters are simultaneously open.