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

struct echipa
{
    int punctaj, goals, lung;
    char nume[101];
};

echipa v[5];
char ch, sir[101];
int l, ind, ind1, gasit, p1, p2;

bool comp(const echipa &A, const echipa &B)
{
    if(A.punctaj!=B.punctaj)
        return A.punctaj>B.punctaj;
    else
    {
        if(A.goals!=B.goals)
            return A.goals>B.goals;
        else
        {
            return A.nume<B.nume;
        }
    }
}

int main()
{
    for(int i=1; i<=6; ++i)
    {
        cin>>sir;
        ind=0;
        for(int j=1; j<=gasit; ++j)
        {
            if(strcmp(v[j].nume, sir)==0)
                ind=j;
        }
        if(!ind)
        {
            ind=(++gasit);
            strcpy(v[ind].nume, sir);
            v[ind].lung=strlen(sir);
        }
        cin>>sir;
        ind1=0;
        for(int j=1; j<=gasit; ++j)
        {
            if(strcmp(v[j].nume, sir)==0)
                ind1=j;
        }
        if(!ind1)
        {
            ind1=(++gasit);
            strcpy(v[ind1].nume, sir);
            v[ind1].lung=strlen(sir);
        }
        cin>>p1>>p2;
        if(p1>p2)
        {
            v[ind].punctaj+=3;
            v[ind].goals+=p1;
            v[ind1].goals+=p2;
        }
        else if(p2>p1)
        {
            v[ind1].punctaj+=3;
            v[ind].goals+=p1;
            v[ind1].goals+=p2;
        }
        else
            {
                v[ind].punctaj+=1;
                v[ind1].punctaj+=1;
                 v[ind].goals+=p1;

                v[ind1].goals+=p2;
            }
    }
    sort(v+1, v+5, comp);
    for(int i=1; i<=4; ++i)
    {
        cout<<v[i].nume<<"\n";
    }
    return 0;
}