#include<iostream>
using namespace std;
struct team
{
	char name[256];
	int  pct;
} team[4];
int main()
{
int c,d;
int j=0;
for(c=0;c<=3;c++)
	team[c].pct=0;



	gets(team[j].name);;
		gets(team[j+1].name);;
		cin>>c;
		cin>>d;
		if(c>d)
			team[j].pct+=3;
		else if(c==d)
			{
			team[j].pct+=1;
		    team[j+1].pct+=1;
			}
		else team[j+1].pct+=3;
		
        gets(team[j+2].name);
		gets(team[j+3].name);
		cin>>c;
		cin>>d;
		if(c>d)
			team[j+2].pct+=3;
		else if(c==d)
			{
			team[j+2].pct+=1;
		    team[j+3].pct+=1;
			}
		else team[j+3].pct+=3;
		
		gets(team[j+0].name);
		gets(team[j+2].name);
		cin>>c;
		cin>>d;
		if(c>d)
			team[j+0].pct+=3;
		else if(c==d)
			{
			team[j+0].pct+=1;
		    team[j+2].pct+=1;
			}
		else team[j+2].pct+=3;
		
		gets(team[j+1].name);
		gets(team[j+3].name);
		cin>>c;
		cin>>d;
		if(c>d)
			team[j+1].pct+=3;
		else if(c==d)
			{
			team[j+1].pct+=1;
		    team[j+3].pct+=1;
			}
		else team[j+3].pct+=3;
	
		gets(team[j+3].name);
		gets(team[j+1].name);
		cin>>c;
		cin>>d;
		if(c>d)
			team[j+3].pct+=3;
		else if(c==d)
			{
			team[j+3].pct+=1;
		    team[j+1].pct+=1;
			}
		else team[j+1].pct+=3;
		
		        gets(team[j+1].name);
		gets(team[j+2].name);
		cin>>c;
		cin>>d;
		if(c>d)
			team[j+1].pct+=3;
		else if(c==d)
			{
			team[j+2].pct+=1;
		    team[j+1].pct+=1;
			}
		else team[j+1].pct+=3;
	struct	team aux[4];
		for(int k=0;k<=3;k++)
			for(int t=k+1;k<=3;t++)
		if(team[k].pct<=team[t].pct)
			{aux[1]=team[t];
			team[t]=team[k];
			team[k]=aux[1];}
			
		for(int p=0;p<=3;p++)
			cout<<team[p].name<<endl;
			
}