#include <iostream>
#include <string>

using namespace std;

int main()
{
    int nr1,nr2;
    int loc = 0;
    string s;
    string aux1;
    string aux2;

    struct {string o;int goal;}v[5];

    for (int i = 1;i <= 6;i++)
    {
        aux1.clear();aux2.clear();
        nr1 = nr2 = 0;
        std::getline(std::cin,s);
        int j = 0;
        while ((s[j] >= 'A' && s[j] <= 'Z') || (s[j] >= 'a' && s[j] <= 'z')) {aux1.append(s,j,1);j++;}
        j++;
        while ((s[j] >= 'A' && s[j] <= 'Z') || (s[j] >= 'a' && s[j] <= 'z')) {aux2.append(s,j,1);j++;}
        j++;
        while (s[j] >= '0' && s[j] <= '9') {nr1 = nr1 * 10 + (s[j] - '0');j++;}
        j++;
        while (s[j] >= '0' && s[j] <= '9') {nr2 = nr2 * 10 + (s[j] - '0');j++;}

        int ok1 = 1;
        int ok2 = 1;

        for (int j = 1;j<=loc;j++)
        {
            if (v[j].o.compare(aux1) == 0)
            {
                if (nr1 > nr2) v[j].goal+=3;
                else if (nr1 == nr2) v[j].goal+=1;

                ok1 = 0;
            }

            if (v[j].o.compare(aux2) == 0)
            {
                if (nr2 > nr1) v[j].goal+=3;
                else if (nr2 == nr1) v[j].goal+=1;

                ok2 = 0;
            }
        }

            if (ok1 == 1)
            {
                loc++;v[loc].o.append(aux1);

                if (nr1 > nr2) v[loc].goal = 3;
                else if (nr1 == nr2) v[loc].goal = 1;
                else v[loc].goal = 0;
            }

            if (ok2 == 1)
            {
                loc++;v[loc].o.append(aux2);

                if (nr2 > nr1) v[loc].goal = 3;
                else if (nr2 == nr1) v[loc].goal = 1;
                else v[loc].goal = 0;
            }
    }

    string nume;
    int chestie;


    for (int i = 1;i < loc;i++)
        for (int j = i + 1;j <= loc;j++)

    {
        nume.clear();chestie = 0;
        if (v[i].goal < v[j].goal) {nume.append(v[i].o);
                                    chestie = v[i].goal;
                                    v[i].o.clear();
                                    v[i].o.append(v[j].o);
                                    v[i].goal = v[j].goal;
                                    v[j].o.clear();
                                    v[j].o.append(nume);
                                    v[j].goal = chestie;}

        else if (v[i].goal == v[j].goal)
        {
            if (v[i].o < v[j].o) {nume.append(v[i].o);
                                            chestie = v[i].goal;
                                            v[i].o.clear();
                                            v[i].o.append(v[j].o);
                                            v[i].goal = v[j].goal;
                                            v[j].o.clear();
                                            v[j].o.append(nume);
                                            v[j].goal = chestie;}
        }
    }

    for (int i = 1;i<=loc;i++) cout<<v[i].o<<endl;
}