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

using namespace std;

struct echipa
{
    char nume[123];
    int puncte;
    int goluri;
};

echipa echipe[5];

char s[505];
int goluri1,goluri2;
int cont1,cont2,total,l;
int team1,team2;
char teamz[5][123];
char team[123];

bool cmp(echipa a, echipa b)
{
    if (a.puncte > b.puncte)
        return false;
    if (a.puncte < b.puncte)
        return true;

    if (a.goluri > b.goluri)
        return false;
    if (a.goluri < b.goluri)
        return true;
}

int main()
{
    for (int meciuri = 1; meciuri <= 6; ++meciuri)
    {


        cin.getline(s,500);
        l = strlen(s);
        int it = 0;

        while (it < l)
        {
            cont1 = 0;
            while ((s[it] >= 'a' && s[it] <= 'z') || (s[it] >= 'A' && s[it] <= 'Z'))
            {
                team[cont1] = s[it];
                cont1++;
                it++;
            }
            it++;

            bool ok = false;

            for (int i = 1; i <= 4; ++i)
            {
                ok = true;
                for (int j = 0; j < cont1; ++j)
                {
                    if (team[j] != echipe[i].nume[j])
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok)
                {
                    team1 = i;
                    break;
                }
            }

            if (!ok)
            {
                total++;
                for (int j = 0; j < cont1; ++j)
                {
                    echipe[total].nume[j] = team[j];
                }
                team1 = total;
            }

            /*for (int j = 0; j < cont1; ++j)
            {
                cout << team[j];
            }
            cout << " ";*/



            cont1 = 0;
            while ((s[it] >= 'a' && s[it] <= 'z') || (s[it] >= 'A' && s[it] <= 'Z'))
            {
                team[cont1] = s[it];
                cont1++;
                it++;
            }
            it++;

            ok = false;

            for (int i = 1; i <= 4; ++i)
            {
                ok = true;
                for (int j = 0; j < cont1; ++j)
                {
                    if (team[j] != echipe[i].nume[j])
                    {
                        ok = false;
                        break;
                    }
                }
                if (ok)
                {
                    team2 = i;
                    break;
                }
            }

            if (!ok)
            {
                total++;
                for (int j = 0; j < cont1; ++j)
                {
                    echipe[total].nume[j] = team[j];
                }
                team2 = total;
            }

            /*for (int j = 0; j < cont1; ++j)
            {
                cout << team[j];
            }
            cout << " ";*/



            goluri1 = 0;
            while(s[it] >= '0' && s[it] <= '9')
            {
                goluri1 = goluri1*10 + int(s[it]-'0');
                it++;
            }
            it++;

            goluri2 = 0;
            while(s[it] >= '0' && s[it] <= '9')
            {
                goluri2 = goluri2*10 + int(s[it]-'0');
                it++;
            }
            it++;


            /*cout << "aici\n";
            cout << goluri1 << " " << goluri2 << '\n';
            cout << team1 << " " << team2 << '\n';*/
        }

        echipe[team1].goluri += goluri1;
        echipe[team2].goluri += goluri2;
        if (goluri1 > goluri2)
        {
            echipe[team1].puncte += 3;
        }
        if (goluri2 > goluri1)
        {
            echipe[team2].puncte += 3;
        }
        if (goluri1 == goluri2)
        {
            echipe[team1].puncte += 1;
            echipe[team2].puncte += 1;
        }

    }



    sort(echipe+1,echipe+5,cmp);

    for (int i = 1; i <= 4; ++i)
    {
        cout << echipe[i].nume << '\n';
    }

    return 0;
}