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

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

using namespace std;

int a, b, i;
string s, t;

map<string, int> p, g;

set<string> S;

struct team
{
    string s;
    int p, g;
};
team A[10];

struct cmp
{
    bool operator () (team x, team y) const
    {
        if(x.p == y.p)
        {
            if(x.g == y.g) return (x.s).compare(y.s) < 0;
            else return x.g > y.g;
        }
        else return x.p > y.p;
    }
};

int main()
{
    cin.sync_with_stdio(false);

    //    freopen("test.in", "r", stdin);
//    freopen("test.out", "w", stdout);

    for(int I = 1; I <= 6; I++)
    {
        cin >> s >> t >> a >> b;

        if(a == b)
        {
            p[s]++;
            p[t]++;
        }
        else if(a > b) p[s] += 3;
        else p[t] += 3;

        g[s] += a;
        g[t] += b;

        S.insert(s);
        S.insert(t);
    }

    for(auto it : S)
    {
        i++;
        A[i].s = it;
        A[i].p = p[it];
        A[i].g = g[it];
        cerr << A[i].s << " " << A[i].p << " " << A[i].g << endl;
    }

    sort(A + 1, A + 5, cmp());

    for(i = 1; i <= 4; i++)
        cout << A[i].s << '\n';

    return 0;
}