#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
struct da
{
    int gol,gas,pct;
};
da a[100];
int i,j,team,jj,scor1,scor2,poz1,poz2;
char s[1005],ss[100][1005],cuv1[1005],cuv2[1005];
int cautare(char s[])
{
    int i;
    bool ok=true;
    for (i=1; i<=team; i++)
    {
        ok=true;
        if (strlen(ss[i])==strlen(s))
        {
            for (j=0; j<strlen(s); j++)
            {
                if (ss[i][j]!=s[j])
                {
                    ok=false;
                    break;
                }
            }
        }
        else ok=false;
        if (ok==true)return i;
    }
    return -1;
}
bool cmp(da y,da x)
{
    int i;
    bool ok1=false,ok2=false;
    if (x.pct<y.pct&&x.gas<y.gas)return true;
    else if (x.pct==y.pct)
    {
        if (x.gol<y.gol&&x.gas<y.gas)return true;
        else
        {
            if (x.gol==y.gol)
            {
                if (strlen(ss[x.gas])>strlen(ss[y.gas])&&x.gas<y.gas)return true;
                else
                {
                    if (strlen(ss[x.gas])==strlen(ss[y.gas]))
                    {
                        for (i=0; i<strlen(ss[x.gas]); i++)
                        {
                            if (ss[x.gas][j]>='A'&&ss[x.gas][j]<='Z')ss[x.gas][j]=char(32+int(ss[x.gas][i])),ok1=true;
                            if (ss[y.gas][j]>='A'&&ss[y.gas][j]<='Z')ss[y.gas][j]=char(32+int(ss[y.gas][i])),ok2=true;
                            if (int(ss[x.gas][i])>int(ss[y.gas][i])&&x.gas<y.gas)
                            {
                                if (ok1==true)ss[x.gas][i]=char(int(ss[x.gas][i])-32);
                                if (ok2==true)ss[y.gas][i]=char(int(ss[y.gas][i])-32);
                                ok1=false;
                                ok2=false;
                                return true;

                            }
                            if (ok1==true)ss[x.gas][i]=char(int(ss[x.gas][i])-32),ok1=false;
                            if (ok2==true)ss[y.gas][i]=char(int(ss[y.gas][i])-32),ok2=false;
                        }
                    }
                }
            }
        }
    }
    return false;
}
int main()
{
    for (i=1; i<=6; i++)
    {
        cin.getline(s,1000);
        j=0;
        while(s[j]!=' ')
        {
            cuv1[j]=s[j];
            j++;
        }
        j++;
        jj=0;
        while(s[j]!=' ')
        {
            cuv2[jj]=s[j];
            jj++;
            j++;
        }
        j++;
        scor1=s[j]-'0';
        j++;
        j++;
        scor2=s[j]-'0';
        if (cautare(cuv1)!=-1)
        {
            poz1=cautare(cuv1);
        }
        else
        {
            team++;
            poz1=team;
            strcpy(ss[team],cuv1);
            a[poz1].gas=team;
        }
        if (cautare(cuv2)!=-1)
        {
            poz2=cautare(cuv2);

        }
        else
        {
            team++;
            poz2=team;
            strcpy(ss[team],cuv2);
            a[poz2].gas=team;
        }
        if (scor1>scor2)
        {
            a[poz1].pct+=3;
            a[poz1].gol+=scor1;
            a[poz2].gol+=scor2;
            a[poz2].gas=team;
        }
        else if (scor2>scor1)
        {
            a[poz2].pct+=3;
            a[poz2].gol+=scor2;
            a[poz1].gol+=scor1;
        }
        else
        {
            a[poz2].pct++;
            a[poz1].pct++;
            a[poz1].gol+=scor1;
            a[poz2].gol+=scor2;
        }
        memset(cuv1,NULL,sizeof(cuv1));
        memset(cuv2,NULL,sizeof(cuv2));
    }
    sort(a+1,a+team+1,cmp);
    for (i=1; i<=4; i++)
    {
        for (j=0; j<strlen(ss[a[i].gas]); j++)
            cout<<ss[a[i].gas][j];
        cout<<"\n";
    }
}