Train ticket office is always busy, especially during the Spring Festival. In those days many people who want train tickets fall in an agony of waiting and no tickets, including Mr. Govern. His awful situation seems to be changed after he got a God's note in an accident.
In the God's note, everything is recorded as a prediction with exact time. The time every person go to buy tickets is also included. And then Mr. Govern wants this to help him. Assuming all people except Mr. Govern will arrive at the ticket office at the integral minute (XX: XX: 00), and Mr. Govern will only arrive there at half minute (XX: XX: 30). At the same time the ticket office should only sell tickets to one person by the order the people arrived and spends T minutes on each consumer. As Mr. Govern should also work every day, he has only a time interval to buy ticket. That is to say, Mr. Govern should arrive at and leave the ticket office within the time interval. You should pay attention that the ticket office opens at 8:00:00 and closes at 17:00:00.
Your task is to tell Mr. Govern when he arrives at the ticket office he can wait for least time.
Input (Please use standard input, and don’t read or write files.) | |
The first line contains two integers N, T. N is the number of people who will buy ticket except Mr. Govern. T is the time each consumer will cost. Then follows N lines. Each line contains a piece of time. The last line contains two pieces of time, means the time interval. All time will be formed as HH:MM:SS by 24-hour system. You can assume all time 0< N <= 1000, 0< T <=60
| |
Output (Please use standard output, and don’t read or write files.) | |
Output a piece of time at which Mr. Govern arrives at the ticket office he can wait for minimum time. This should be also formed as HH:MM:SS. If there are more than one answers, output the earliest one. If Mr. Govern cannot buy a ticket this day, output one line “Poor Mr. Govern!” without double quotation marks. | |
| |
Sample Input | Sample Output |
3 5 09:30:00 16:00:00 16:30:00 15:59:00 16:59:00
| 15:59:30 |
把所有的时间都转化成秒。排序后,先对队列中的时间按小到大排序,接着,估计完成时间。然后,将Mr. Govern的时间插入,在估计完成时间,找出等待时间最短的。