#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <map>

#define ll long long
#define ull unsigned long long

using namespace std;

struct echipa {
    string nume;
    int punctaj, goluri;
} A[5];

bool cmp(echipa a, echipa b) {
    if (a.punctaj == b.punctaj && a.goluri == b.goluri)
        return a.nume < b.nume;
    if (a.punctaj == b.punctaj)
        return a.goluri > b.goluri;
    return a.punctaj > b.punctaj;
}

int main() {
    
    string a, b, Echipe[5];
    int cnt = 0;
    map <string, int> M, G;
    int a1, b1;
    for (int i = 1; i <= 6; i++) {
        cin >> a >> b >> a1 >> b1;
        G[a] += a1, G[b] += b1;
        if (a1 > b1)
            M[a] += 3;
        else if (b1 > a1)
            M[b] += 3;
        else
            M[a] += 1, M[b] += 1;
        bool ok = false;
        for (int j = 1; j < 5; j++)
            if (Echipe[j] == a) {
                ok = true;
                break;
            }
        if (!ok) {
            cnt++;
            Echipe[cnt] = a;
        }
        ok = false;
        for (int j = 1; j < 5; j++)
            if (Echipe[j] == b) {
                ok = true;
                break;
            }
        if (!ok) {
            cnt++;
            Echipe[cnt] = b;
        }
    }
    
    for (int i = 1; i <= 4; i++) {
        A[i].nume = Echipe[i];
        A[i].punctaj = M[Echipe[i]];
        A[i].goluri = G[Echipe[i]];
    }
    
    sort(A+1, A+4+1, cmp);
        
    for (int i = 1; i <= 4; i++)
        cout << A[i].nume << "\n";
    
    return 0;
}