// Round1x.cpp : Defines the entry point for the console application.
//

#include<iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
using namespace std;
std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems) {
	std::stringstream ss(s);
	std::string item;
	while (std::getline(ss, item, delim)) {
		elems.push_back(item);
	}
	return elems;
}
std::vector<std::string> split(const std::string &s, char delim) {
	std::vector<std::string> elems;
	split(s, delim, elems);
	return elems;
}
int rev(int x)
{
	int y = 0;
	while (x)
	{
		y = 10 * y + x % 10;
		x = x / 10;
	}
	return y;
}
int cons(int x)
{
	while (x>9)
	{
		int c = x % 10;
		c--;
		x = x / 10;
		if (c != x % 10)
			return 0;
	}
	return 1;
}
struct team{ string name; int score; int goals; }t[4];
void sortScore(struct team* students, int n) {
	int j, i;

	for (i = 1; i<n; i++)
	{
		for (j = 0; j<n - i; j++)
		{
			if (students[j].score <students[j + 1].score)
			{
				struct team temp = students[j];
				students[j] = students[j + 1];
				students[j + 1] = temp;
			}
		}
	}
}
void sortGoals(struct team* students, int n) {
	int j, i;

	for (i = 1; i<n; i++)
	{
		for (j = 0; j<n - i; j++)
		{
			if (students[j].goals <students[j + 1].goals)
			{
				struct team temp = students[j];
				students[j] = students[j + 1];
				students[j + 1] = temp;
			}
		}
	}
}
void sortAlpha(struct team* students, int n) {
	int j, i;

	for (i = 1; i<n; i++)
	{
		for (j = 0; j<n - i; j++)
		{
			if (!students[j].name.compare(students[j + 1].name))
			{
				struct team temp = students[j];
				students[j] = students[j + 1];
				students[j + 1] = temp;
			}
		}
	}
}
int main()
{
	int x = 6;
	string s;

	t[0].name = " ";
	t[1].name = " ";
	t[2].name = " ";
	t[3].name = " ";
	t[0].score = 0;
	t[1].score = 0;
	t[2].score = 0;
	t[3].score = 0;
	t[0].goals = 0;
	t[1].goals = 0;
	t[2].goals = 0;
	t[3].goals = 0;
	for (int i = 0; i < x; i++)
	{
		string x[4];
		cin >> x[0];
		cin >> x[1];
		cin >> x[2];
		cin >> x[3];
		int v1 = atoi(x[2].c_str());
		int v2 = atoi(x[3].c_str());
		if (v1 == v2)
		{
			for (int j = 0; j < 4; j++)
			{
				if (t[j].name == x[0])
				{
					t[j].score++;
					t[j].goals += v1;
					break;
				}
			}
			for (int j = 0; j < 4; j++)
			{
				if (t[j].name == x[1])
				{
					t[j].goals += v2;
					t[j].score++;
					break;
				}
			}
			for (int j = 0; j < 4; j++)
			{
				if (t[j].name == " ")
				{
					t[j].name = x[0];
					t[j].score++;
					t[j].goals = v2;
					break;
				}
			}
			for (int j = 0; j < 4; j++)
			{
				if (t[j].name == " ")
				{
					t[j].name = x[1];
					t[j].score++;
					t[j].goals = v2;
					break;
				}
			}
		}
		if (v1 > v2)
		{
			for (int j = 0; j < 4; j++)
			{
				if (t[j].name == x[0])
				{
					t[j].goals += v1;
					t[j].score += 3;
					break;
				}
			}
			for (int j = 0; j < 4; j++)
			{
				if (t[j].name == x[1])
				{
					t[j].goals += v2;
					t[j].score += 0;
					break;
				}
			}
			for (int j = 0; j < 4; j++)
			{
				if (t[j].name == " ")
				{
					t[j].goals += v1;
					t[j].name = x[0];
					t[j].score += 3;
					break;
				}
			}
			for (int j = 0; j < 4; j++)
			{
				if (t[j].name == " ")
				{
					t[j].goals += v2;
					t[j].name = x[1];
					t[j].score += 0;
					break;
				}
			}
		}
		if (v1 < v2)
		{
			for (int j = 0; j < 4; j++)
			{
				if (t[j].name == x[0])
				{
					t[j].goals += v1;
					t[j].score += 0;
					break;
				}
			}
			for (int j = 0; j < 4; j++)
			{
				if (t[j].name == x[1])
				{
					t[j].goals += v2;
					t[j].score += 3;
					break;
				}
			}
			for (int j = 0; j < 4; j++)
			{
				if (t[j].name == " ")
				{
					t[j].goals += v1;
					t[j].name = x[0];
					t[j].score += 0;
					break;
				}
			}
			for (int j = 0; j < 4; j++)
			{
				if (t[j].name == " ")
				{
					t[j].goals += v2;
					t[j].name = x[1];
					t[j].score += 3;
					break;
				}
			}
		}
	}
	sortAlpha(t, 4);
	sortGoals(t, 4);
	sortScore(t, 4);
	for (int i = 0; i < 4; i++)
	{
		cout << t[i].name <<'\n';
	}
	cin >> x;
	return 0;
}