human
Everyone knows that 2010 FIFA World Cup is being held in South Africa now. By the decision of BFA (Berland's Football Association) next World Cup will be held in Berland. BFA took the decision to change some World Cup regulations:

  * the final tournament features n teams (n is always even) 
  * the first n / 2 teams (according to the standings) come through to the knockout stage 
  * the standings are made on the following principle: for a victory a team gets 3 points, for a draw — 1 point, for a defeat — 0 points. In the first place, teams are ordered in the standings in decreasing order of their points.
in the second place — in decreasing order of the difference between scored and missed goals.
in the third place — in the decreasing order of scored goals 
  * it's written in Berland's Constitution that the previous regulation helps to order the teams without ambiguity. 


You are asked to write a program that, by the given list of the competing teams and the results of all the matches, will find the list of teams that managed to get through to the knockout stage.

Input

The first input line contains the only integer n (1 ≤ n ≤ 50) — amount of the teams, taking part in the final tournament of World Cup. The following n lines contain the names of these teams, a name is a string of lower-case and upper-case Latin letters, its length doesn't exceed 30 characters. The following n·(n - 1) / 2 lines describe the held matches in the format name1-name2 num1:num2, where name1, name2 — names of the teams.
num1, num2 (0 ≤ num1, num2 ≤ 100) — amount of the goals, scored by the corresponding teams. Accuracy of the descriptions is guaranteed: there are no two team names coinciding accurate to the letters' case.
there is no match, where a team plays with itself.
each match is met in the descriptions only once.

Output

Output n / 2 lines — names of the teams, which managed to get through to the knockout stage in lexicographical order. Output each name in a separate line. No odd characters (including spaces) are...
Solve the task in PYTHON3.
 ... What is a Python program to find the list of teams that managed to get through to the knockout stage?
assistant
#Here is Python program to find the list of teams that managed to get through to the knockout stage.

class Info:
    def __init__(self, _team_name, _points, _goal_diff, _scored_goals):
        self.TeamName = _team_name
        self.Points = _points
        self.GoalDiff = _goal_diff
        self.ScoredGoals = _scored_goals

# end of class
# our function here
def findIndexByTeamName(container, team_name):
    for ind, item in enumerate(container):
        if item.TeamName == team_name:
            return ind

    return -1

# end of our functions here

N = int(input())
cont = list()
for i in range(N):
    cont.append(Info(input(), 0, 0, 0))

for i in range(N * (N - 1) // 2):
    s = input()
    dashIndex = s.index('-')
    spaceIndex = s.index(' ')
    colonIndex = s.index(':')
    Team1Name = s[0:dashIndex]
    Team2Name = s[dashIndex + 1:spaceIndex]
    Goal1 = int(s[spaceIndex + 1:colonIndex])
    Goal2 = int(s[colonIndex + 1:])
    Team1Index = findIndexByTeamName(cont, Team1Name)
    Team2Index = findIndexByTeamName(cont, Team2Name)

    # update points
    if Goal1 > Goal2:
        cont[Team1Index].Points += 3
    elif Goal1 < Goal2:
        cont[Team2Index].Points += 3
    else:
        cont[Team1Index].Points += 1
        cont[Team2Index].Points += 1

    # update goal difference
    cont[Team1Index].GoalDiff += (Goal1 - Goal2)
    cont[Team2Index].GoalDiff += (Goal2 - Goal1)

    # scored goals
    cont[Team1Index].ScoredGoals += Goal1
    cont[Team2Index].ScoredGoals += Goal2

# Sorting by points then by goalDiff and then scored goals
cont.sort(key=lambda item: (item.Points, item.GoalDiff, item.ScoredGoals), reverse=True)
# remove second half of pour list
del cont[N // 2:]
# sort by team name
cont.sort(key=lambda item: item.TeamName)
# output
for item in cont:
    print(item.TeamName)