#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;

string teams[4];
int points[4];

int main()
{
	string team1, team2;
	int p1, p2;
	for (int i = 0; i < 6; i++)
	{
		cin >> team1 >> team2 >> p1 >> p2;
		int pos1 = -1, pos2 = -1;
		for (int j = 0; j < 4 && (pos1 == -1 || pos2 == -1); j++)
			if (teams[j].size() == 0)
			{
				if (pos1 == -1)
				{
					pos1 = j;
					teams[j] = team1;

				}
				else
					if (pos2 == -1)
					{
						pos2 = j;
						teams[j] = team2;
					}
			}
			else
				if (pos1 == -1 && teams[j] == team1)
					pos1 = j;
				else
					if (pos2 == -1 && teams[j] == team2)
						pos2 = j;
		if (p1 == p2)
		{
			points[pos1] += 1;
			points[pos2] += 1;
		}
		else
		{
			if (p1 > p2)
				points[pos1] += 3;
			else
				points[pos2] += 3;
		}				
	}
	sort(points, points + 4, greater<int>());
	for (int i = 0; i < 4; i++)
		cout << teams[i] << "\n";
	return 0;
}