#include <iostream>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

typedef struct {
	int p, gf;
} pct;

map <string, pct> m;
map <string, pct>::iterator it;
vector <string> v;
string s1, s2;
int x, y;

bool Comp(string a, string b){
	if(m[a].p == m[b].p){
		if(m[a].gf == m[b].gf)
			return a < b;
		return m[a].gf > m[b].gf;
	}
	return m[a].p > m[b].p;
}

int main(){
	
	int i, n = 6;

	while(n--){
		cin >> s1 >> s2 >> x >> y;
		//cout << s1 <<' ' <<  s2 << '\n';
		if(m.find(s1) == m.end()){
			m[s1].p = 0; m[s1].gf = 0;
			v.push_back(s1);
		}
		if(m.find(s2) == m.end()){
			m[s2].p = 0; m[s2].gf = 0;
			v.push_back(s2);
		}

		if(x < y)
			m[s2].p += 3;
		else
			if(x > y)
				m[s1].p += 3;
			else{
				m[s1].p++; m[s2].p++;
			}

		m[s1].gf += x;
		m[s2].gf += y;
	}

	sort(v.begin(), v.end(), Comp);
	for(i = 0; i < 4; i++)
		cout << v[i] << '\n';

	return 0;
}