#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
using namespace std;

struct echipa {
    string nume;
    int g;
    int p;
    echipa(string _nume = "", int _g = 0, int _p = 0) {
        nume = _nume;
        g = _g;
        p = _p;
    }
    
    inline bool operator <(const echipa &o) const{
        if(p == o.p) {
            if(g == o.g) {
                return nume < o.nume;
            }
            return g > o.g;
        }
        return p > o.p;
    }
};

map<string, int> puncte;
map<string, int> goluri;

int main() {
    for(int i = 1; i <= 6; i++) {
        string a, b;
        int ga, gb;
        cin >> a >> b >> ga >> gb;
        goluri[a] += ga;
        goluri[b] += gb;
        
        if(ga == gb) {
            puncte[a] = puncte[a] + 1;
            puncte[b] = puncte[b] + 1;
        }
        else if(ga > gb) {
            puncte[a] = puncte[a] + 3;
        }
        else {
            puncte[b] = puncte[b] + 3;
        }
    }
    
    vector<echipa> v;
    for(auto it : goluri) {
        v.push_back(echipa(it.first, it.second, puncte[it.first]));
    }
    sort(v.begin(), v.end());

    for(auto it : v) {
        cout << it.nume << '\n';
    }
}