scoreboard, goalboard = {}, {} for _ in range(0, 6): teamA, teamB, goalsA, goalsB = raw_input().split() goalsA, goalsB = map(int, [goalsA, goalsB]) if goalsA > goalsB: scoreA, scoreB = 3, 0 elif goalsA == goalsB: scoreA, scoreB = 1, 1 else: scoreA, scoreB = 0, 3 if not teamA in scoreboard: scoreboard[teamA], goalboard[teamA] = 0, 0 if not teamB in scoreboard: scoreboard[teamB], goalboard[teamB] = 0, 0 scoreboard[teamA] += scoreA scoreboard[teamB] += scoreB goalboard[teamA] += goalsA goalboard[teamB] += goalsB 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]))])