A food-delivery company employs two couriers. Both couriers start work at the same moment every morning, at the start of the day, time t=0 minutes. Orders arrive during the day, and for each order the following is known:
An order is assigned to a free courier (one not currently working on any order at that moment) who could complete it the fastest. If both couriers are busy at that moment, the customer turns to another company and the order is lost.
If a courier finishes a previous order at exactly the minute a new order arrives, that courier is considered free at that moment.
The couriers finish work once they have completed every order received during the day.
Compute how much each courier earns during the day.
The first line contains the number of orders M. Each of the next M lines describes one order, in the order t v z1 z2:
Print two integers on one line: the total earnings of the first and of the second courier that day, respectively.