#include <iostream>
#include <map>
#include <string>
#include <string.h>
#include <stdlib.h>

using namespace std;

string fin[100];

int main()
{
    map<string, int> echipe;
    string e1, e2;
    int s1, s2;
    char str[2049];
    map<string, int> gol;
    for(int i = 0; i < 6; i ++)
    {
        cin >> str;
        e1 = str;
        cin >> str;
        e2 = str;
        cin >> str;
        s1 = atoi(str);
        cin >> str;
        s2 = atoi(str);
        //cout << "e1" << e1 << endl << "e2" << e2 << endl << endl;
        if(s1 > s2)
        {
            gol[e1] += s1;
            gol[e2] += s2;
            echipe[e1] += 3;
            echipe[e2] += 0;
        }
        else if(s1 < s2)
        {
            gol[e1] += s1;
            gol[e2] += s2;
            echipe[e2] += 3;
            echipe[e1] += 0;
        }
        else
        {
            gol[e1] += s1;
            gol[e2] += s2;
            echipe[e1] += 1;
            echipe[e2] += 1;
        }
    }

    int v[5];//punctele echipei
    string echip[5];
    int gl[5];
    int i = 0;
    for(map<string, int>::iterator it = echipe.begin(); it != echipe.end(); it ++)
    {
        v[i] = it->second;
        echip[i] = it->first;
        i ++;
    }
    i = 0;
    for(map<string, int>::iterator it = gol.begin(); it != gol.end(); it ++)
    {
        gl[i ++] = it->second;
    }
    for(int i = 0; i < 3; i ++)
        for(int j = i + 1; j < 4; j ++)
            if(v[i] < v[j])
            {
                int aux = v[i];
                v[i] = v[j];
                v[j] = aux;

                string auxs = echip[i];
                echip[i] = echip[j];
                echip[j] = auxs;

                aux = gl[i];
                gl[i] = gl[j];
                gl[j] = aux;
            }
/*    for(int i = 0; i < 3; i ++)
        for(int j = i + 1; j < 4; j ++)
            if(v[i] == v[j] && )*/

    for(int k = 0; k <= 3; k ++)
    {
        cout << echip[k] << endl;
    }
    return 0;
}