#! /usr/bin/python import sys teams = {} for line in sys.stdin: line = line.strip() teamA, teamB, goalsA, goalsB = line.split() goalsA = int(goalsA) goalsB = int(goalsB) pointsA, pointsB = 1, 1 if goalsA > goalsB: pointsA, pointsB = 3, 0 elif goalsA < goalsB: pointsA, pointsB = 0, 3 if teamA not in teams: teams[teamA] = pointsA else: teams[teamA] += pointsA if teamB not in teams: teams[teamB] = pointsB else: teams[teamB] += pointsB for team in sorted(teams, key=lambda x:teams[x], reverse=True): print team