Overall Ranking
InterviewTime limit1sMemory limit1024 MB
Given team names listed by regional rank, output the universities sorted by the average of their team ranks, lowest average first.
Problem
The Regional Competitions of ICPC (International Collegiate Programming Contest) allow universities to enter more than one team in the contest. The scoresheet for the contest lists the ranking for each team. For example, if UCF has three teams, GT two teams, and Auburn four teams, the final team ranking may look like:
- Auburn
- GT
- UCF
- UCF
- UCF
- Auburn
- Auburn
- GT
- Auburn
The regional contest does not show the overall performance of each university. The overall performance is the average of the team rankings for the university. For the scoresheet above, Auburn has an overall performance of (1 + 6 + 7 + 9) / 4 = 5.75, UCF has (3 + 4 + 5) / 3 = 4.0, and GT has (2 + 8) / 2 = 5.0. So the overall ranking of the universities is:
- UCF
- GT
- Auburn
A lower average means better performance, so it gives a higher university ranking.
Assume that no two universities have the same overall performance. No tiebreaker is needed.
Input
The first line contains an integer n (2 ≤ n ≤ 100), the number of teams in the regional contest. The next n lines list the teams, one per line, in the order of their regional ranking. Each team name is 1 to 20 letters (uppercase and/or lowercase). The input contains at least two universities.
Output
Print the universities, one per line, in the order of overall performance.