An automatic machine is used in a factory for controlling entrance and exit of workers. Each worker has an electronic identification (ID) card that has to be inserted into the machine every time the worker enters or leaves the factory. The machine reads the name (say S) from the ID card, and the current date (say, D) and time (say, T) from its internal timer, and generates a new record, denoted by D–S–T, in its database. The entrance time is no sooner than 8:00:00, and the exit time is no later than 20:00:00.
The factory also has a watchman who is always present and carefully records the entrances and exits of all workers and of the clients. He creates a separate list each day that contains the names of the people (workers or clients) who enter or exit the factory during that day. The list is in the same order as the people enter or exit. The names of workers on this list are exactly the same strings as recorded by the automatic machine. Note that clients do not have ID cards.
It is quite possible that some workers forget to insert their ID cards into the machine. But, we assume that each worker makes this mistake at most once each day. We also know that each worker that comes to work in the factory on a certain day, enters the factory exactly once and leaves it exactly once on that day.
At the end of the month, and on the pay day, the director of the factory notes that, with the information recorded by the automatic machine and the lists prepared by the watchman, it is not possible to find out exactly how many hours each worker has been present (working) in the factory in the past month. He, therefore, decides to pay each worker 100K Rials multiplied by the "average" time he/she has been present in the factory during these days. The “average” time is computed as the average of two numbers: one is the minimum possible and the other is the maximum possible time the worker has been present in the factory during the working days in the past month.
You are to write a program to find out the minimum and the maximum possible time each worker has been present in the factory.
In the first line of input, there is an integer t (1≤ t ≤10), the number of test cases, followed by the data for the test cases. Each line of a test case is a record of machine database or reports of watchman at the end of a day. Each line representing a machine record is like D–S–T, where S is a string of lower case letters, D is a date, formatted like YY/MM/DD, and T is a time stamp, formatted like HH:MM:SS. There is no blank character in this kind of input lines. Each line representing a watchman's report of a single day containing 1 ≤ k ≤ 40 names like the following:
The output file contains answers to the test cases with the ith answer corresponding to the ith test case. Each line of an answer is of the form:
2 99/10/03-sarah-09:00:00 99/10/03-sarah-14:00:00 99/10/04-ali-17:00:00 99/10/03-maryam-09:02:00 99/10/03-ali-10:20:15 99/10/04 ali reza sarah hamid ali reza sarah hamid 99/10/03-ali-12:00:00 99/10/03-maryam-09:04:00 99/10/04-sarah-18:00:00 99/10/03 sarah maryam maryam hamid hamid ali hassan ali sarah hassan 99/10/04-ali-13:00:00 # 99/10/03-sarah-09:00:00 99/10/03-sarah-14:00:00 99/10/04-ali-17:00:00 99/10/03-ali-10:20:15 99/10/04 ali sarah ali sarah 99/10/03-ali-12:00:00 99/10/04-sarah-18:00:00 99/10/03 sarah ali ali sarah 99/10/04-ali-13:00:00 #
ali-5 39 45-5 39 45 maryam-0 2 0-0 2 0 sarah-6 0 0-10 0 0 # ali-5 39 45-5 39 45 sarah-6 0 0-10 0 0 #