#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>

using namespace std;

map <string, int> echipe;

string st[4];

void swap_Str(int x, int y)
{
    string temp_s;
        temp_s = st[x];
        st[x] = st[y];
        st[y] = temp_s;
}

int main()
{
    char a[50], b[50];
    int x, y, i;
    //fscanf(stdin, "%s %s %d %d", a);
    for (i = 0; i < 6; ++i)
    {
        cin >> a >> b >> x >> y;
        if (x > y)
        {
            x = -3;
            y = 0;
        } else if (x < y)
        {
            x = 0;
            y = 3;
        }
        else
        {
            x = y = 1;
        }
        echipe[a] = x + echipe[a];
        echipe[b] = y + echipe[b];

    }
    i = 0;

    for( map<string, int>::iterator ii=echipe.begin(); ii!=echipe.end(); ++ii)
    {
        st[i++] = (*ii).first;
    }
    if (echipe[st[0]] < echipe[st[1]] )
    {
        swap_Str(0, 1);
    }
    if (echipe[st[0]] < echipe[st[2]] )
    {
        swap_Str(0, 2);
    }
    if (echipe[st[0]] < echipe[st[3]] )
    {
       swap_Str(0, 3);
    }
    if (echipe[st[1]] < echipe[st[2]] )
    {
       swap_Str(1, 2);
    }
    if (echipe[st[1]] < echipe[st[3]] )
    {
       swap_Str(1, 3);
    }
    if (echipe[st[2]] < echipe[st[3]] )
    {
        swap_Str(2, 3);
    }

    for (i = 0; i < 4; ++i)
    {
        cout << st[i] << '\n';
    }
    return 0;
}