#include <cstdio>
#include <string>
#include <string.h>
#include <algorithm>
using namespace std;
int i;
char  a[5000];
string n1,n2;
int s1,s2,nr1,nr2,cn,j,lim;
bool ok;

struct cp
{
    string name;
    int scor;
    int gol;
};
cp v[5];

bool cmp(cp X, cp Y)
{
  if ( X.scor != Y.scor )
  {
      return ( X.scor > Y.scor );
  }
  else
  {
    if ( X.gol != Y.gol )
        return( X.gol > Y.gol );
    else
    {
        return ( X.name.compare(Y.name) < 0 );
    }
  }
}


inline bool lit(char c)
{
    if (c>='a' && c<='z') return true;
    if (c>='A' && c<='Z') return true;
    return false;
}
inline bool cif(char c)
{
    if (c>='0' && c<='9') return true;
    return false;
}


int main()
{

 //   freopen("input.txt","r",stdin);

    cn=0;
    for (i=1;i<=6;i++)
    {
        scanf("%s",a);


        j = 0;

        n1 = n2 = "";
        nr1 = nr2 = 0;

        while ( lit(a[j]) )
        {
            n1 += a[j++];
        }

        scanf("%s",a);
        j=0;

         while ( lit(a[j]) )
        {
            n2 += a[j++];
        }

        scanf("%s",a);
        j=0;

        while ( cif(a[j]) )
        {
            nr1 = nr1*10 + (a[j++]-'0');
        }

       scanf("%s",a);
        lim = strlen(a);
        j=0;

        while ( j<lim &&  cif(a[j]) )
        {
            nr2 = nr2*10 + (a[j++]-'0');
        }

        if (nr1 < nr2 )
        {
            s1 = 0;
            s2 = 3;
        }
        if (nr1 > nr2)
        {
            s1 = 3;
            s2 = 0;
        }
        if (nr1 == nr2)
        {
            s1 = s2 = 1;

        }


        ok = false;

        for (j=1;j<=cn;j++)
            if (v[j].name.compare(n1) == 0)
            {
                 ok =true;
                 v[j].scor += s1;
                 v[j].gol += nr1;
            }

        if (ok == false)
        {
            cn++;
            v[j].name = n1;
            v[j].scor = s1;
            v[j].gol = nr1;
        }

        ok = false;
        for (j=1;j<=cn;j++)
            if (v[j].name.compare(n2) == 0)
            {
                 ok =true;
                 v[j].scor += s2;
                 v[j].gol += nr2;
            }

        if (ok == false)
        {
            cn++;
            v[j].name = n2;
            v[j].scor = s2;
            v[j].gol = nr2;
        }
    }


   for (i=1;i<=4;i++)
        for (j=i+1;j<=4;j++)
        {
            if (v[i].scor < v[j].scor)
            {
                swap(v[i],v[j]);
                continue;
            }
            else
            if (v[i].scor == v[j].scor)
            {
                if (v[i].gol < v[j].gol)
                {
                    swap(v[i],v[j]);
                    continue;
                }
                else
                    if (v[i].gol == v[j].gol)
                if (v[i].name.compare(v[j].name) > 0)
                {
                    swap(v[i],v[j]);
                    continue;

                }
            }
        }

    for (i=1;i<=4;i++)
    {
        printf("%s",v[i].name.c_str());
        if (i<4) printf("\n");
    }



    return 0;
}