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

struct echipa
{
    int punctaj, nr;
};

echipa v[5];
char ch, sir[101], x[5][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
    {
        return (strcmp(x[B.nr], x[A.nr]))>0;
    }
}

int main()
{
    for(int i=1; i<=6; ++i)
    {
        cin.get(sir, 100, ' ');
        cin.get();
        ind=0;
        for(int j=1; j<=gasit; ++j)
        {
            for(int k=0; k<100; ++k)
            {
                if(x[j][k]!=sir[k])
                    goto pas;
            }
            ind=j;
            pas: ;
        }
        if(!ind)
        {
            ind=(++gasit);
            strcpy(x[ind], sir);
            v[ind].nr=ind;
        }
        cin.get(sir, 101, ' ');
        ind1=0;
        for(int j=1; j<=gasit; ++j)
        {
            for(int k=0; k<100; ++k)
            {
                if(x[j][k]!=sir[k])
                    goto p;
            }
            ind1=j;
            p: ;
        }
        if(!ind1)
        {
            ind1=(++gasit);
            strcpy(x[ind1], sir);
            v[ind1].nr=ind1;
        }
        cin>>p1>>p2;
        if(p1>p2)
            v[ind].punctaj+=3;
        else if(p2>p1)
            v[ind1].punctaj+=3;
        else
            {
                v[ind].punctaj+=1;
                v[ind1].punctaj+=1;
            }
        cin.get();
    }
    sort(v+1, v+5, comp);
    for(int i=1; i<=4; ++i)
    {
        cout<<x[v[i].nr]<<"\n";
    }
    return 0;
}