#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

struct team
{
    char name[101];
    int points;
    int goals;
}teams[4];

bool comparet(team t1, team t2)
{
    if(t1.points!=t2.points)return t1.points>t2.points;
    if(t1.goals!=t2.goals)return t1.goals>t2.goals;
    return strcmp(t1.name,t2.name)<0;
}

int main()
{
    char s1[101];
    int g1;
    int found1;
    char s2[101];
    int g2;
    int found2;
    teams[0].name[0] = teams[1].name[0] = teams[2].name[0] = teams[3].name[0] = '\0';
    for(int i=1;i<=6;i++)
    {
        cin>>s1>>s2>>g1>>g2;
        int found1 = found2 = -1;
        for(int j=0;j<4;j++)
        {
            if(teams[j].name[0]=='\0')
            {
                if(found1==-1){found1=j; strcpy(teams[j].name,s1);}
                else if(found2==-1){found2=j; strcpy(teams[j].name,s2);}
            }
            else
            {
                if(strcmp(s1,teams[j].name)==0)
                {
                    found1=j;
                }
                if(strcmp(s2,teams[j].name)==0)
                {
                    found2=j;
                }
            }
        }
        if(g1<g2)
        {
            teams[found2].points+=3;
        }
        else if(g1==g2)
        {
            teams[found1].points+=1;
            teams[found2].points+=1;
        }
        else
        {
            teams[found1].points+=3;
        }
        teams[found1].goals+=g1;
        teams[found2].goals+=g2;
    }

    sort(teams,teams+4,comparet);

    for(int i=0;i<4;i++)
        cout<<teams[i].name<<'\n';

    return 0;
}