A factory uses an automatic machine to control when workers enter and leave. Every worker carries an electronic ID card that must be inserted into the machine each time the worker enters or leaves. On each insertion the machine reads the name S from the card and the current date D and time T from its clock, then stores one record D-S-T. An entrance is never recorded before 08:00:00, and an exit is never recorded after 20:00:00.
The factory also has a watchman on permanent duty. Each day he writes down every person -- worker or client -- who enters or leaves, in the exact order the events occur. A worker's name is written exactly as the machine records it. Clients carry no ID card, so they never appear in the machine records.
Some workers forget to insert their card, but each worker forgets at most once per day. Every worker who comes in on a given day enters exactly once and leaves exactly once that day.
For a worker on one day, the time spent in the factory is (exit time) − (entrance time); the total over the period is the sum over all working days. Because of forgotten insertions the exact totals cannot always be recovered. On pay day the director pays each worker in proportion to the average of two values: the minimum and the maximum total time the worker could possibly have been present. For each worker, compute that minimum and that maximum.
The first line contains an integer t (1≤t≤10), the number of test cases. Each test case is a sequence of lines; every line is either a machine record or a watchman report.
D-S-T with no spaces: S is a string of lowercase letters (a worker's name), D is a date in the format YY/MM/DD, and T is a time in the format HH:MM:SS.D S1 S2 ... Sk with 1≤k≤40: D is a date, and S1, S2, ..., Sk are names separated by single blanks, listed in the order the people entered or left on that day.There is at most one watchman report per date. Each test case covers at most 30 days. Every name has at most 15 characters, and no two people share a name. Each test case has between 1 and 15 employees. Two records on the same date may share a timestamp; then the watchman may list those events in any order. Each test case ends with a line containing a single #.
For each test case, print one line for every worker (every name that appears in at least one machine record):
S-H1 M1 S1-H2 M2 S2
Here S is the worker's name, H1 M1 S1 are the hours, minutes and seconds of the minimum possible total presence time, and H2 M2 S2 are the same for the maximum possible total presence time. Within each triple the numbers are separated by single blanks and printed without leading zeros. Sort the lines by S in dictionary order. End each test case's answer with a line containing a single #.