#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

typedef struct _team
{
    string name;
    int points;
    int goalsScored;
    int goalsIncasated;
} Team;

vector<Team> teams;

bool f(Team t1, Team t2)
{
    if(t1.points > t2.points)
    {
        return true;
    }
    if(t1.points < t2.points)
    {
        return false;
    }

    if(t1.goalsScored > t2.goalsScored)
    {
        return true;
    }
    if(t1.goalsScored < t2.goalsScored)
    {
        return false;
    }

    return t1.name > t2.name;
}

int main()
{
    string t1, t2;
    int g1, g2;
    for(int i = 0; i < 6; i++)
    {
        cin >> t1 >> t2 >> g1 >> g2;
        if(g1 < g2)
        {
            swap(t1, t2);
            swap(g1, g2);
        }

        bool team1Found = false;
        bool team2Found = false;

        for(int j = 0; j < (int)(teams.size()); j++)
        {
            if(teams[j].name == t1)
            {
                team1Found = true;
                teams[j].goalsScored += g1;
                teams[j].goalsIncasated += g2;
                
                if(g1 == g2)
                {
                    teams[j].points += 1;
                }
                else
                {
                    teams[j].points += 3;
                }
            }
            if(teams[j].name == t2)
            {
                team2Found = true;
                teams[j].goalsIncasated += g1;
                teams[j].goalsScored += g2;

                if(g1 == g2)
                {
                    teams[j].points += 1;
                }
                else
                {
                    teams[j].points += 0;
                }
            }
        }

        if(!team1Found)
        {
            Team t;
            t.name = t1;
            t.goalsScored = g1;
            t.goalsIncasated = g2;
            if(g1 == g2)
            {
                t.points = 1;
            }
            else
            {
                t.points = 3;
            }
            teams.push_back(t);
        }

        if(!team2Found)
        {
            Team t;
            t.name = t2;
            t.goalsScored = g2;
            t.goalsIncasated = g1;
            if(g1 == g2)
            {
                t.points = 1;
            }
            else
            {
                t.points = 0;
            }
            teams.push_back(t);
        }
    }

    sort(teams.begin(), teams.end(), f);

    for(int i = 0; i < 4; i++)
    {
        cout << teams[i].name << '\n'; // << teams[i].points << ' ' << teams[i].goalsScored << ' ' << teams[i].goalsIncasated << '\n';
    }

    return 0;
}