Under construction

Still being built. Things may change

Overall Ranking

Interview

Time limit1sMemory limit1024 MB

Summary
Given team names listed by regional rank, output the universities sorted by the average of their team ranks, lowest average first.
Level

Easy3 of 10

Topics
Hash map, Sorting
Solved
No attempts yet

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:

  1. Auburn
  2. GT
  3. UCF
  4. UCF
  5. UCF
  6. Auburn
  7. Auburn
  8. GT
  9. 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:

  1. UCF
  2. GT
  3. 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.

Examples3

  1. Example 1

    Input
    9
    Auburn
    GT
    UCF
    UCF
    UCF
    Auburn
    Auburn
    GT
    Auburn
    
    Expected output
    UCF
    GT
    Auburn
    
  2. Example 2

    Input
    7
    UofX
    UofA
    UofC
    UofB
    UofA
    UofB
    UofY
    
    Expected output
    UofX
    UofC
    UofA
    UofB
    UofY
    
  3. Example 3

    Input
    8
    UA
    UB
    UA
    UA
    UA
    ua
    Ua
    uA
    
    Expected output
    UB
    UA
    ua
    Ua
    uA