#include <iostream>
#include <algorithm>
#include <cstring>
#include <fstream>

using namespace std;

int n,m;
char a[100],aux[100];
struct echipa{
int s,g;
char nume[100];
};
echipa r[5];

int cmp(echipa AA,echipa BB)
{
    if(AA.s==BB.s)
        return AA.g>BB.g;
    return AA.s>BB.s;
}
int main()
{
    int i,j,q,w,e=0,poz1=0,poz2=0,AUX1,AUX2;
    for(q=1;q<=6;q++)
    {
        cin.get(a,100);
        cin.get();
        i=0;
            poz1=0,poz2=0;
            j=0;
            while(isalpha(a[i]))
            {
                aux[j]=a[i];
                i++;
                j++;
            }
            aux[j]='\0';
            for(w=1;w<=e;w++)
            {
                if(!strcmp(aux,r[w].nume))
                {
                    poz1=w;
                    w=e+1;
                }
            }
            if(w==e+1)
            {
                e++;
                poz1=e;
                strcpy(r[e].nume,aux);
            }
            while(j)
            {
                aux[j]=0;
                j--;
            }
            i++;
            j=0;
            while(isalpha(a[i]))
            {
                aux[j]=a[i];
                i++;
                j++;
            }
            aux[j]='\0';
            for(w=1;w<=e;w++)
            {
                if(!strcmp(aux,r[w].nume))
                {
                    poz2=w;
                    w=e+1;
                }
            }
            if(w==e+1)
            {
                e++;
                poz2=e;
                strcpy(r[e].nume,aux);
            }
            while(j)
            {
                aux[j]=0;
                j--;
            }
            i++;
            AUX1=0;
            while(isdigit(a[i]))
            {
                AUX1*=10;
                AUX1+=a[i]-'0';
                i++;
            }
            r[poz1].g+=AUX1;
            i++;
            AUX2=0;
            while(isdigit(a[i]))
            {
                AUX2*=10;
                AUX2+=a[i]-'0';
                i++;
            }
            r[poz2].g+=AUX2;
        if(AUX2>AUX1)
            r[poz2].s+=3;
        else if(AUX2==AUX1)
            r[poz2].s++,r[poz1].s++;
        else r[poz1].s+=3;
    }
    sort(r+1,r+5,cmp);
    for(i=1;i<=4;i++)
    {
        cout<<r[i].nume<<"\n";
    }
    return 0;
}