Swimming pool
In indoor swimming competitions, stronger swimmers are typically placed in the middle lanes for better visual perception, while weaker swimmers are positioned on the outer lanes. For instance, in a pool with 6 lanes, the top swimmer is assigned to lane 3, the second-best to lane 4, the third to lane 2, the fourth to lane 5, the fifth to lane 1, and the sixth to lane 6. Additionally, every effort is made to fill all lanes in each heat, ensuring that at least half of the pool's lanes are occupied. Athletes prefer to compete against stronger opponents, so they are not placed in weaker heats unless necessary.
In this scenario, we are considering a pool with 6 lanes. You are provided with preliminary results for a particular distance, consisting of a list of athletes' surnames and their results (a string and a real number). Your task is to establish a system that assigns a heat number and lane number to an athlete based on their surname and preliminary results.
Input Data:
The first line of input contains a single integer K, representing the number of athletes (3 ≤ K ≤ 50). The following K lines each contain an athlete's surname and their preliminary result (a string and a real number). There are no duplicate surnames or results. The last line contains the surname of the athlete for whom you need to determine the heat number and lane number.
Output Data:
Output two integers, the heat number and the lane number, separated by a space. If the athlete is not found in the heats, output the message "Missing".
Explanation of the Example:
In the first heat: lane 1 – sidorov, lane 2 – koss, lane 3 – bas, lane 4 – kolos, lane 5 – tkachov, lane 6 – sych.
In the second heat: lane 1 – free, lane 2 – oskol, lane 3 – lol, lane 4 – ivanov, lane 5 – petrov, lane 6 – free.