Roman roads are famous for their longevity and sound engineering. Unfortunately, sound engineering does not come cheap, and a number of neo-Caesars have decided to recover the costs through automated tolling.
A particular toll highway, the CDVII, has a very simple fare structure that works as follows: travel on the road costs a certain amount per km traveled. Cameras at every entrance and every exit capture the license numbers of all cars entering and leaving. Every calendar month, a bill is sent to the registered owner for each km traveled, plus one dollar per completed trip, plus a two dollar account charge (provided that at least one completed trip was made). Your job is to prepare the bill for one month, given a set of license plate photos.
The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.
Each input case contains the fare (a positive integer on a line by itself), the number of photo records (a positive integer on a line by itself) and the actual photo records (each one occurring on a line by itself on consecutive lines of the input file). The fare denotes the toll in cents/km to travel on the road. Each photo record consists of the license number of the vehicle (up to 20 alphanumeric characters - you may assume that all alphabetical characters will be uppercase), the day, hour, minute and second (dd:hh:mm:ss), the word "enter" or "exit", and the location of the entrance or exit (in km from one end of the highway). All dates will be within a single month. Each "enter" record is paired with the chronologically next record for the same vehicle provided it is an "exit" record. "enter" records that are not paired with an "exit" record are ignored, as are "exit" records not paired with an "enter" record. You may assume that no two records for the same vehicle have the same time. Times are recorded using a 24-hour clock. There are not more than 1000 photo records.
For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.
Print a line for each vehicle indicating the license number, followed by a single space, followed by the dollar sign ($), followed by the total bill. The output should appear in ascending alphabetical order by license number. Vehicles that have an account bill of $0.00 shouldn't be listed.
1 10 4 ABCD123 01:01:06:01 enter 17 765DEF 01:01:07:00 exit 30 ABCD123 01:01:08:03 exit 95 765DEF 01:01:05:59 enter 40
765DEF $4.00 ABCD123 $10.80