#include <bits/stdc++.h>

using namespace std;

string line;
map<string, int> pts;
map<string, int> goals;
vector<string> teams;

bool cmp(string a, string b) {
	if (pts[a] != pts[b]) {
		return pts[a] > pts[b];
	}
	if (goals[a] != goals[b]) {
		return goals[a] > goals[b];
	}
	return a < b;
}

int main() {
//	freopen("date.in", "r", stdin);
//	freopen("date.out","w", stdout);
	cin.sync_with_stdio(false);
	
	for (int i = 0; i < 6; i++) {
		getline(cin, line);
		stringstream ss(line);
		string A, B;
		int ga, gb;
		ss >> A >> B >> ga >> gb;
		goals[A] += ga;
		goals[B] += gb;
		if (ga > gb) {
			pts[A] += 3;
		}
		else if (ga < gb) {
			pts[B] += 3;
		}
		else {
			pts[A] += 1;
			pts[B] += 1;
		}
		teams.push_back(A);
		teams.push_back(B);
	}
	
	sort(teams.begin(), teams.end());
	teams.resize(unique(teams.begin(), teams.end()) - teams.begin());
	
	sort(teams.begin(), teams.end(), cmp);
	
	for (vector<string> :: iterator it = teams.begin(); it != teams.end(); it++) {
		cout << *it << endl;
	}
	
	return 0;
}