#include <fstream>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>

#define DIM 100
#define vint vector<int>::iterator
#define pint vector< pair<int, int> >::iterator
#define sint set<int>::iterator
#define infile "test.in"
#define outfile "test.out"

using namespace std;

char teams[10][100];

char aux[100];

int points[10], goals[10];

char s1[100], s2[100];

int g1, g2;

int main() {

	int nrTeams = 0;

	for (int i = 1; i <= 6; ++i) {

		cin >> s1 >> s2 >> g1 >> g2;

		int j;

		for (j = 1; j <= nrTeams; ++j)
			if (strcmp(teams[j], s1) == 0)
				break;

		if (j == nrTeams + 1) {

			++nrTeams;
			strcpy(teams[nrTeams], s1);

			goals[nrTeams] += g1;

			if (g1 > g2)
				points[nrTeams] += 3;

			if (g1 == g2)
				points[nrTeams] += 1;

		}
		else {

			goals[j] += g1;

			if (g1 > g2)
				points[j] += 3;

			if (g1 == g2)
				points[j] += 1;

		}

		for (j = 1; j <= nrTeams; ++j)
			if (strcmp(teams[j], s2) == 0)
				break;

		if (j == nrTeams + 1) {

			++nrTeams;
			strcpy(teams[nrTeams], s2);

			goals[nrTeams] += g2;

			if (g1 < g2)
				points[nrTeams] += 3;

			if (g1 == g2)
				points[nrTeams] += 1;

		}
		else {
			goals[j] += g1;

			if (g1 < g2)
				points[j] += 3;

			if (g1 == g2)
				points[j] += 1;

		}

	}

	for (int i = 1; i < 4; ++i) {
		for (int j = i + 1; j <= 4; ++j) {
		
			if (points[i] < points[j]) {

				swap(points[i], points[j]);
				swap(goals[i], goals[j]);
				strcpy(aux, teams[i]);
				strcpy(teams[i], teams[j]);
				strcpy(teams[j], aux);

			}

			if (points[i] == points[j] && goals[i] < goals[j]) {

				swap(points[i], points[j]);
				swap(goals[i], goals[j]);
				strcpy(aux, teams[i]);
				strcpy(teams[i], teams[j]);
				strcpy(teams[j], aux);

			}

			if (points[i] == points[j] && goals[i] == goals[j] && strcmp(teams[i], teams[j]) > 0) {

				swap(points[i], points[j]);
				swap(goals[i], goals[j]);
				strcpy(aux, teams[i]);
				strcpy(teams[i], teams[j]);
				strcpy(teams[j], aux);

			}
		
		}
	}

	for (int i = 1; i <= 4; ++i)
		cout << teams[i] << '\n';

	return 0;
}

//Trust me, I'm the Doctor!