#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

vector< pair<string,pair<int,int> > > echipe;
int s1,s2,g1,g2;

void addScor(string e,int g,int s)
{
	int ok=0;
	for(unsigned int i=0;i<echipe.size();++i){
		if(echipe[i].first == e){
			echipe[i].second.first+=s;
			echipe[i].second.second+=g;
			ok = 1;
		}
	}
	if(ok == 0){
		echipe.push_back( make_pair( e, make_pair(s,g)));
	}
}

void sort()
{

	for(unsigned int i=0;i<echipe.size()-1;++i)
		for(int j=i+1;j<echipe.size();++j){

			int s1 = echipe[i].second.first;
			int s2 = echipe[j].second.first;
			int g1 = echipe[i].second.second;
			int g2 = echipe[j].second.second;
			if( s1 > s2 ){
				continue;
			}
			else if(s1 == s2 && g1 > g2){
				continue;
			}
			else if( s1 == s2 && g1 == g2 && echipe[i].first > echipe[j].first){
				continue;
			}
			swap(echipe[i],echipe[j]);
		}
}

int main()
{
	string e1,e2;
	int g1,g2;

	for(int i=0;i<6;++i){
		cin>>e1>>e2>>g1>>g2;
		if(g1 > g2){
			s1 = 3; s2 = 0;
		}
		else if(g2 > g1){
			s2 = 3; s1=0;
		}
		else { 
			s1=1; s2=1;
		}

		addScor(e1,g1,s1);
		addScor(e2,g2,s2);		
	}

	sort();
	for(unsigned int i=0;i<echipe.size();++i){
		cout<<echipe[i].first<<endl; 	
	}
		
	return 0;
}