At one of the major European train stations, there are 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.
The first line contains an integer (0 < N \leq 1000), representing the number of ticket counters. Each of the next lines contains integers separated by spaces. The first two integers represent the opening time in hours and minutes (hours range from to , and minutes range from to ). 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 hours minutes to hours minutes, it operates for minutes each day. If the opening and closing times are the same, the counter operates 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 a single number representing the total number of minutes per day during which all counters are simultaneously open.
Example 1