#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <set>
#include <algorithm>
using namespace std;

ifstream fin("t.in");
ofstream fout("t.out");

vector<string> v;
vector<int> sol;
set<string> S;
string team1, team2;
int go1, go2;
int points[20], goals[20];

struct cmp {
    bool operator()(int A, int B) {
        if (points[A] > points[B]) return true;
        if (points[A] < points[B]) return false;
        if (goals[A] > goals[B]) return true;
        if (goals[A] < goals[B]) return false;
        return v[A].compare(v[B]);
    }
};

int main() {
    for (int i = 0; i < 6; ++i) {
        cin >> team1 >> team2 >> go1 >> go2;
        if (S.find(team1) == S.end()) {
            S.insert(team1);
            v.push_back(team1);
        }
        if (S.find(team2) == S.end()) {
            S.insert(team2);
            v.push_back(team2);
        }
        for (int j = 0; j < (int)v.size(); ++j) {
            if (v[j] == team1) {
                goals[j] += go1;
                if (go1 > go2) {
                    points[j] += 3;
                }else if (go1 == go2) {
                    points[j] += 1;
                }
            }
            if (v[j] == team2) {
                goals[j] += go2;
                if (go1 < go2) {
                    points[j] += 3;
                }else if (go1 == go2) {
                    points[j] += 1;
                }
            }
        }
    }
    for (int i = 0; i < 4; ++i)
        sol.push_back(i);
    sort(sol.begin(), sol.end(), cmp());
    for (int i = 0; i < 4; ++i) {
        cout << v[ sol[i] ] << '\n';
    }
    fin.close();
    fout.close();
    return 0;
}