!Economize


  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Mr. AA, BB, and CC 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 AA, BB and CC 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 AA, BB and CC in the same order. In each line a number kk is given and afterwards 2k2k strings are given in the format HH:MM:SSHH:MM:SS each string is a given time with HHHH being the hour MMMM being the minute and SSSS being the second. This means from the time between the first and second , 33rd and 44th , 55th and 66th , ... , 2k12k-1 and 2k2k that particular person does not have power.

0k100 \le k \le 10 0HH<240 \le HH \lt 24 0MM<600 \le MM \lt 60 0SS<600 \le SS \lt 60

If there is not any power from second ll to second rr it means the interval is inclusive meaning there is no electricity from the beginning of second ll till the end of second rr in the interval [l,r][l , r].

The given HHHH, MMMM and SSSS all have 2 digits for example for representing 6 o'clock in the format it should be written as 06:00:0006:00:00

خروجی🔗

Output the first time they can have that meeting in the HH:MM:SSHH:MM:SS format, meaning they can start talking for 15 minutes in hour HHHH minute MMMM and second SSSS. If they cannot talk for 15 at all you should output "1-1".

مثال🔗

ورودی نمونه ۱🔗

1 00:01:02 03:04:05
1 06:07:08 09:10:11
0
Plain text

خروجی نمونه ۱🔗

03:04:06
Plain text

ورودی نمونه ۲🔗

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
Plain text

خروجی نمونه ۲🔗

-1
Plain text