import re

#f = open ( 'input2.txt', 'rb' )
#data = f.read()



teams = []
points = [0,0,0,0]
goals = [0,0,0,0]

for q in range ( 6 ):
	data = raw_input()

	#print data
	for line in re.finditer ( '^(.*) (.*) ([0-9]*) ([0-9]*)$', data ):
		team1 = line.groups()[0]
		team2 = line.groups()[1]
		sc1 = int (line.groups()[2])
		sc2 = int (line.groups()[3])
		if len(teams)<4:
			if team1 not in teams:
				teams.append ( team1 )
			if team2 not in teams:
				teams.append ( team2 )
			
		for i in range ( 4 ):
			if team1 == teams[i]:
				break
		for j in range ( 4 ):
			if team2 == teams[j]:
				break
		#print line.groups()
		#print teams
		#print i
		#print j
		#print "NEXT!"
		goals[i] += sc1
		goals[j] += sc2
		if sc1 == sc2:
			points[i] += 1
			points[j] += 1
			continue
		if sc1 > sc2:
			points[i] += 3
	
#print teams
#print points
#print goals


for i in range ( 0,3 ):
	for j in range ( i+1, 4 ):
		if points [ i ] < points [ j ]:
			aux = points [ i ]
			points [i] = points [j]
			points [j] = aux
			
			aux = teams[i]
			teams[i] = teams[j]
			teams[j] = aux
			
			aux = goals[i]
			goals[i] = goals[j]
			goals[j] = aux

for i in range ( 3 ):
	j = i + 1
	if ( points[i] == points[j] ) and ( goals[i] < goals[j] ):
		aux = points [ i ]
		points [i] = points [j]
		points [j] = aux
		
		aux = teams[i]
		teams[i] = teams[j]
		teams[j] = aux
		
		aux = goals[i]
		goals[i] = goals[j]
		goals[j] = aux
		continue;
	if ( points[i] == points[j] ) and ( goals[i] == goals[j] ) and ( teams[i] > teams[j] ):
		aux = points [ i ]
		points [i] = points [j]
		points [j] = aux
		
		aux = teams[i]
		teams[i] = teams[j]
		teams[j] = aux
		
		aux = goals[i]
		goals[i] = goals[j]
		goals[j] = aux
	



for team in teams:
	print team