+ Time Limit : 1 second
+ Memory Limit : 256 megabytes
Mr. $A$, $B$, and $C$ have decided to organize a programming contest so *Shengdebao* can take part in it! To make the contest they have to arrange a meeting and talk today but they are quite tired and decided to start a video chat instead.
For the video chat to be beneficial they have to talk constantly for exactly 15 minutes and to do this their computer systems should be plugged and have electricity.
The thing is $A$, $B$ and $C$ live in different locations of the city and due to the over usage of electricity the power department of the city cuts down the power of various locations in some time intervals.
For these three people we know exactly when their power will be cut! You should find out exactly the first time they can start their video chat meeting for 15 minutes. To clarify, you should say the starting time of the 15 minutes interval which all of the three have power and can start the video chat that also ends until 12:00 am!
The input contains 3 lines each denoting the intervals in which they don't have any electricity. The first, second and third line indicates the times for $A$, $B$ and $C$ in the same order. In each line a number $k$ is given and afterwards $2k$ strings are given in the format $HH:MM:SS$ each string is a given time with $HH$ being the hour $MM$ being the minute and $SS$ being the second. This means from the time between the first and second , $3$rd and $4$th , $5$th and $6$th , ... , $2k-1$ and $2k$ that particular person does not have power.
$$0 \le k \le 10 $$
$$0 \le HH \lt 24$$
$$0 \le MM \lt 60$$
$$0 \le SS \lt 60$$
If there is not any power from second $l$ to second $r$ it means the interval is **inclusive** meaning there is no electricity from the beginning of second $l$ till the end of second $r$ in the interval $[l , r]$.
The given $HH$, $MM$ and $SS$ all have 2 digits for example for representing 6 o'clock in the format it should be written as $06:00:00$
Output the first time they can have that meeting in the $HH:MM:SS$ format, meaning they can start talking for 15 minutes in hour $HH$ minute $MM$ and second $SS$. If they cannot talk for 15 at all you should output "$-1$".
## Sample input 1
1 00:01:02 03:04:05
1 06:07:08 09:10:11
## Sample output 1
## Sample input 2
1 00:00:00 23:55:00
1 05:06:07 08:00:00
2 01:11:59 22:21:20 22:21:21 22:21:21
## Sample output 2
ارسال پاسخ برای این سؤال
برای ارسال پاسخ باید ابتدا وارد سایت شوید.
کپی سؤال «!Economize»
ویژه اساتید و دستیاران آموزشی
با استفاده از این امکان، میتوانید از سؤالات موجود در بانک سؤالات کپی بگیرید و آنها را
به تمرینهای درس خود و یا مسابقات خود اضافه کنید.
مقصد کپی شدن این سؤال را انتخاب کنید. نکته: پیش از اقدام به کپی، باید در درس خود یک تمرین ایجاد کنید.