#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int n,i,e1,e2,gol1,gol2,k,j;
char aux[101];
char sir[101];
char *p;
char echipa1[31],echipa2[31];
struct echipe
{
    int p,g;
    char nume[31];
}team[5];
int cmp(echipe a, echipe b)
{
    if(a.p<b.p) return 0;
    else if(a.p==b.p)
    {
        if(a.g<b.p) return 0;
        else if(a.g==b.g)
        {
            if(strcmp(a.nume,b.nume)>0) return 0;
        }
    }
    return 1;
}

int main()
{
    for(i=1;i<=6;++i)
    {
        e1=-1; e2=-1;
        cin.getline(sir,101);
        p=strtok(sir," ");
        strcpy(echipa1,p);
        //e1=hash(p);
        p=strtok(NULL," ");
        strcpy(echipa2,p);
        //e2=hash(p);
        p=strtok(NULL," ");
        strcpy(aux,p);
        if(aux[1]!=NULL)
        {
            gol1=(aux[0]-'0')*10+aux[1]-'0';
        }
        else gol1=aux[0]-'0';

        p=strtok(NULL," ");
        strcpy(aux,p);
        if(aux[1]!=NULL)
        {
            gol2=(aux[0]-'0')*10+aux[1]-'0';
        }
        else gol2=aux[0]-'0';

        for(j=1;j<=k;++j) if(strcmp(echipa1,team[j].nume)==0) {e1=j; break;}
        if(e1==-1) ++k,strcpy(team[k].nume,echipa1);
        for(j=1;j<=k;++j) if(strcmp(echipa2,team[j].nume)==0) {e2=j; break;}
        if(e2==-1) ++k,strcpy(team[k].nume,echipa2);

        if(gol1>gol2)
        {
            team[e1].p+=3;
        }
        else if(gol2>gol1)
        {
            team[e2].p+=3;
        }
        else
        {
            team[e2].p+=1;
            team[e1].p+=1;
        }
        team[e1].g+=gol1;
        team[e2].g+=gol2;
    }
    sort(team+1,team+1+4,cmp);
    for(i=1;i<=4;++i) cout<<team[i].nume<<'\n';
    return 0;
}