#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cstring>
#include <string>

using namespace std;

unordered_map<string, int> score, goals;
set<string> S;

struct cmp {
	inline bool operator() (const string &a, const string &b) {
		if (score[a] != score[b]) {
			return score[a] > score[b];
		}
		if (goals[a] != goals[b]) {
			return goals[a] > goals[b];
		}
		return a < b;
	}
};

int main() {

	#ifndef ONLINE_JUDGE
	freopen("a.in", "r", stdin);
	freopen("a.out", "w", stdout);
	#endif

	for (int i = 1; i <= 6; ++i) {
		string t1, t2; int g1, g2;
		cin >> t1 >> t2 >> g1 >> g2;
		if (g1 > g2) {
			score[t1] += 3;
		} else if (g1 == g2) {
			score[t1] += 1;
			score[t2] += 1;
		} else {
			score[t2] += 3;
		}
		goals[t1] += g1;
		goals[t2] += g2;
		S.insert(t1);
		S.insert(t2);
	}

	vector<string> V;
	for (string s : S) {
		V.push_back(s);
	}

	sort(V.begin(), V.end(), cmp());

	for (string s : V) {
		cout << s << "\n";
	}

	return 0;
}