Swimming pool

(The original statement in Catalan has some private jokes. This English version goes straight to the point of the problem.)

There is a swimming pool with some free slots of time. There are two rules:

Input

Input consists of several cases. Every case begins with the number of slots nn, followed by nn pairs of triplets h1h_1:m1m_1:s1s_1 h2h_2:m2m_2:s2s_2, which indicate that there is a slot from h1h_1:m1m_1:s1s_1 until h2h_2:m2m_2:s2s_2. Assume 1n10001 \le n \le 1000, that hours are between 0 and 23, that minutes are between 0 and 59, and that h1h_1:m1m_1:s1s_1 is smaller than h2h_2:m2m_2:s2s_2. The end of input is marked with a special case with n=0n = 0.

Output

For every case, print the maximum number of seconds that you can swim.

Problem information

Author: Lander Ramos

Generation: 2026-01-25T10:00:27.920Z

© Jutge.org, 2006–2026.
https://jutge.org