#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

#define dbg(x) (cout<<#x<<" = "<<(x)<<'\n')
#ifdef HOME
const string inputFile = "input.txt";
const string outputFile = "output.txt";
#else
const string problemName = "";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
#endif

typedef long long int lld;
typedef pair<int, int> PII;
typedef pair<int, lld> PIL;
typedef pair<lld, int> PLI;
typedef pair<lld, lld> PLL;

const int INF = (1LL << 31) - 1;
const lld LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int MOD = (int)(1e9) + 7;

const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int KMAX = 100000 + 5;
const int PMAX = 100000 + 5;
const int LMAX = 100000 + 5;
const int VMAX = 100000 + 5;

map<string, PII> score;
vector<string> V;

bool cmp(string A, string B) {
    if(A == B)
        return 1;

    if(score[A].first == score[B].first) {
        if(score[A].second == score[B].second)
            return A < B;
        return score[A].second > score[B].second;
    }
    return score[A].first < score[B].first;
}

int main() {
    int i, x, y;
    string A, B;

#ifndef ONLINE_JUDGE
    freopen(inputFile.c_str(), "r", stdin);
    freopen(outputFile.c_str(), "w", stdout);
#endif

    for(i = 1; i <= 6; i++) {
        cin >> A;
        cin >> B;
        cin >> x;
        cin >> y;

        if(score.count(A) == 0)
            score[A] = make_pair(0, 0);

        if(score.count(B) == 0)
            score[B] = make_pair(0, 0);

        if(x > y)
            score[A].first = score[A].first + 3;
        if(x < y)
            score[B].first = score[B].first + 3;
        if(x == y) {
            score[A].first = score[A].first + 1;
            score[B].first = score[B].first + 1;
        }

        score[A].second = score[A].second + x;
        score[B].second = score[B].second + y;

        V.push_back(A);
        V.push_back(B);
    }

    sort(V.rbegin(), V.rend(), cmp);
    unique(V.begin(), V.end());

    for(int i = 0; i < 4; i++)
        cout << V[i] << '\n';

    return 0;
}