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.