#include <cstdio>
#include <cstring>
#include <algorithm>


using namespace std;

char teamA[100], teamB[100];
int scoreA, scoreB, N;

struct Team {
    int points, goals;
    char name[100];
}T[10000];

bool inA = false, inB = false;
int main () {


    for (int line = 0 ; line< 6; ++line) {
        scanf("%s %s %d %d", teamA, teamB, &scoreA, &scoreB);
        if (scoreA < scoreB) {
            swap(scoreA, scoreB);
            swap(teamA, teamB);
        }
        for (int i=0; i<N; ++i) {
            if (strcmp(teamA, T[i].name) == 0) {
                T[i].goals += scoreA;
                if (scoreA != scoreB)
                    T[i].points += 3;
                else
                    T[i].points += 1;
                inA = true;
            }
            if (strcmp(teamB, T[i].name) == 0) {
                T[i].goals += scoreB;
                if (scoreA == scoreB)
                    T[i].points += 1;
                inB = true;
            }
        }

        if (!inA) {
            strcpy(T[N].name, teamA);
            T[N].goals = scoreA;
                if (scoreA > scoreB)
                    T[N].points += 3;
                else
                    T[N].points += 1;
            ++N;
        }
        if (!inB) {
            strcpy(T[N].name, teamB);
            T[N].goals = scoreA;
            if (scoreA == scoreB)
                T[N].points += 1;
            ++N;
        }

    }


        for (int i=0; i<N-1; ++i)
            for (int j=i+1; j<N; ++j)
                if (T[i].points < T[j].points)
                    swap(T[i], T[j]);
                else if (T[i].points == T[j].points) {
                    if (T[i].goals < T[j].goals)
                        swap(T[i], T[j]);
                    else if (T[i].goals == T[j].goals) {
                        if (strcmp(T[i].name, T[j].name) > 0)
                            swap(T[i], T[j]);
                    }
                }

    for (int i=0; i<4; ++i) {
        printf("%s\n", T[i].name);
    }

    return 0;
}