scoreboard, goalboard = {}, {}
    2 
    3 for _ in range(0, 6):
    4     teamA, teamB, goalsA, goalsB = raw_input().split()
    5     goalsA, goalsB = map(int, [goalsA, goalsB])
    6 
    7     if goalsA > goalsB: scoreA, scoreB = 3, 0
    8     elif goalsA == goalsB: scoreA, scoreB = 1, 1
    9     else: scoreA, scoreB = 0, 3
   10 
   11     if not teamA in scoreboard: scoreboard[teamA], goalboard[teamA] = 0, 0
   12     if not teamB in scoreboard: scoreboard[teamB], goalboard[teamB] = 0, 0
   13 
   14     scoreboard[teamA] += scoreA
   15     scoreboard[teamB] += scoreB
   16 
   17     goalboard[teamA] += goalsA
   18     goalboard[teamB] += goalsB
   19 
   20 print '\n'.join(["%s" % x[2] for x in sorted([(scoreboard[x], goalboard[x], x) for x in scoreboard], key=lambda x: (-x[0], -x[1], x[2]))])