#include <cstdio>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;
char a[128], b[128];
int ga, gb;
map<string, int> score, goluri;
set<string> countries;

struct nod {
    string name;
    int score, goals;
    nod(){};
    nod(string n, int s, int g) {
        name = n; score = s; goals = g;
    }
};
struct cmp {
    bool operator()(const nod &a, const nod &b) const {
        if (a.score != b.score)
            return a.score > b.score;
        if (a.goals != b.goals)
            return a.goals > b.goals;
        return a.name < b.name;
    }
};
vector<nod> v;
int main() {
    //freopen ("b.in", "r", stdin);

    for (int i = 0; i < 6; ++i) {

        scanf ("%s %s %d %d", &a, &b, &ga, &gb);

        goluri[a] += ga;
        goluri[b] += gb;

        if (ga == gb)
            score[a] += 1,
            score[b] += 1;
        else if (ga > gb)
            score[a] += 3;
        else 
            score[b] += 3;

        countries.insert(a);
        countries.insert(b);
        memset(a, 0, sizeof(a));
        memset(b, 0, sizeof(b));
    }

    for (set<string>::iterator it = countries.begin(); it != countries.end(); ++it)
        v.push_back(nod(*it, score[*it], goluri[*it] ) );
        //printf ("%s %d\n", it->first, it->second);
    sort(v.begin(), v.end(), cmp());

    for (int i = 0; i < v.size(); ++i)
        printf ("%s\n", v[i].name.c_str());
}