#include <iostream>
#include <fstream>
#include <map>
#include <cstring>
using namespace std;

map<string, int> team;

char teams[5][200];
int goals[5];
int points[5];
int poz[5];

int comparare(char a[200], char b[200])
{
	int i, j;
	int nr1, nr2,max;
	nr1 = strlen(a);
	nr2 = strlen(b);
	if (nr1 > nr2) max = nr1;
	else max = nr2;

	for (i = 1; i <= max; i++)
	{
		if (a[i] > b[i]) return 1;
	}
	if (nr2 > nr1) return 1;
	return 0;
}

int main()
{
	int i,j;
	char team1[200], team2[200];
	int score1, score2;
	int k = 0;
	for (i = 1; i <= 6; i++)
	{
		cin >> team1 >> team2 >> score1 >> score2;
		map<string, int>::const_iterator it1 = team.find(team1);
		if (it1 != team.end())
		{
			goals[it1->second] += score1;
			if (score1 > score2) points[it1->second] += 3;
			else if (score1 == score2) points[it1->second] += 1;
		}
		else
		{
			team.insert(pair<string, int>(team1, ++k));
			strcpy(teams[k], team1);
			goals[k] += score1;
			if (score1 > score2) points[k] += 3;
			else if (score1 == score2) points[k] += 1;
		}

		map<string, int>::const_iterator it2 = team.find(team2);

		if (it2 != team.end())
		{
			goals[it2->second] += score2;
			if (score2 > score1) points[it2->second] += 3;
			else if (score1 == score2) points[it2->second] += 1;
		}
		else
		{
			team.insert(pair<string, int>(team2, ++k));
			strcpy(teams[k], team2);
			goals[k] += score2;
			if (score2 > score1) points[k] += 3;
			else if (score1 == score2) points[k] += 1;

		}
	}

	for (i = 1; i <= 4; i++) poz[i] = i;

	for (i = 1; i < 4; i++)
	{
		for (j = i + 1; j <= 4; j++)
		{
			if (points[i]<points[j] || points[i]==points[j] && goals[i]<goals[j] || points[i]==points[j] && goals[i]==goals[j] && comparare(teams[i],teams[j]) == 1)
			{
				int aux;
				aux = goals[i];
				goals[i] = goals[j];
				goals[j] = aux;
				aux = poz[i];
				poz[i] = poz[j];
				poz[j] = aux;

				char aux2[200];
				strcpy(aux2, teams[i]);
				strcpy(teams[i], teams[j]);
				strcpy(teams[j], aux2);
			}
		}
	}

	for (i = 1; i <= 4; i++)
	{
		cout << teams[i] << "\n";
	}
	return 0;
}