A suitable car is a necessity for a spy. A rental company called BAPC keeps a wide selection of cars that suit a spy, and it also takes care of everything that happens after a car comes back. Looking after a car that a spy returns costs money. The tank has to be refilled, and in most cases the wrecked car has to be repaired.
At the end of each year, every spy who used the company pays for the cars driven that year. Last week the management system broke badly and can no longer be used. All that was salvaged is the car information and part of last year's event log. The company wants to work out each spy's bill by hand from what is left.
Every car is registered with its price, an initial rental fee, and an extra charge for each kilometer driven. An event record is a pick-up, a return, or an accident. A spy who picks up a car pays that car's initial rental fee. On returning it, the spy pays the extra charge in proportion to the distance driven up to the moment of return. If the car was wrecked in an accident during the rental, the repair is billed as well. Every accident record stores the damage rate of the car, and the repair cost is the price of that car multiplied by the damage rate. A cost with a fractional part is rounded up before it is added to the bill.
The list of cars was recovered in full, but the event log stayed broken. Sending spies bills that do not add up would cost the company a lot of trust, so you want to write a program that decides whether the surviving event log is consistent. A consistent log satisfies all of the following.
The first line contains the number of test cases, which is at most 100.
Each test case is laid out as follows.
p (pick-up), a string C: the name of the car that was picked upr (return), an integer d: the distance driven, in kilometersa (accident), an integer s (0≤s≤100): the damage rate of the carCar names and spy names are 1 to 40 lowercase letters long. Each test case has at most 500 spies, and the events are given in the order they happened.
For each test case, sort the spies that appear in the event log by name in lexicographic order and print one per line.
INCONSISTENT in place of the total.Do not print a blank line between test cases.