Barbershop
In the barber shop has one master. He spends per customer was 20 minutes and then immediately goes to the next in line if someone is, or is waiting for the next customer comes.
Given the arrival times of customers in the barber shop (in the order in which they came).
Likewise, each client has hrakteristika called the degree of impatience. It shows how people can make the most is in the queue to the client, so he waited his turn and not gone before. If the arrival of the customer in the queue is more people than the degree of impatience, he decides not to wait for their turn and go. The client, who served at the moment as well considered to be in the queue.
Required for each client to specify the time of his exit from the barbershop.
Input
The first line introduces a positive integer N, does not exceed 100 - the number of customers.
The next N lines are introduced arrival times of customers - by two numbers indicating the hours and minutes (hours - from 0 to 23 minutes - 0 to 59) and the degree of impatience (non-negative integer not greater than 100) - maximum number of people who he is willing to wait in front of him in line. Times are listed in ascending order (all times are different).
It is guaranteed that all customers will have time to serve until midnight.
If for some customers end time of one customer service and time of arrival of another match, we can assume that in the beginning of the end of the first customer service, and then comes the second client.
Output
The output file output N pairs of numbers: the time of exit from the barber shop of the 1st, 2nd, ..., N-th customer (hours and minutes). If the arrival of the client's people waiting in line more than a degree of impatience, we can assume that the time of his departure came the same time.