#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <cstdio>
#include <climits>

#define PII pair < int , int >
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define LL long long
#define NMAX 1007

using namespace std;

pair < pair < int , int > , string > c[5];
int cu,s1,s2,p1,p2,i,j;
char t1[NMAX],t2[NMAX];
string team1,team2;
bool found;

string get(char t[])
{
    string q;

    for (int i=0,k=strlen(t);i<k;++i)
    q.push_back(t[i]);

    return q;
}

int main()
{
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
freopen("a.out","w",stdout);
#endif

for (i=1;i<=6;++i)
{
    scanf("%s%s%d%d",t1,t2,&s1,&s2);

    team1=get(t1);
    team2=get(t2);

    p1=p2=0;

    if (s1>s2) p1=3;
    else if (s2>s1) p2=3;
         else p1=p2=1;

    found=false;
    for (j=1;j<=cu;++j)
    if (c[j].S==team1)
    {
        c[j].F.F-=p1;
        c[j].F.S-=s1;
        found=true;
    }

    if (!found)
    {
        ++cu;
        c[cu].F.F-=p1;
        c[cu].F.S-=s1;
        c[cu].S=team1;
    }

    found=false;
    for (j=1;j<=cu;++j)
    if (c[j].S==team2)
    {
        c[j].F.F-=p2;
        c[j].F.S-=s2;
        found=true;
    }

    if (!found)
    {
        ++cu;
        c[cu].F.F-=p2;
        c[cu].F.S-=s2;
        c[cu].S=team2;
    }
}

sort(c+1,c+5);

for (i=1;i<=4;++i)
{
    for (j=0;j<(c[i].S).size();++j)
    printf("%c",(c[i].S)[j]);

    printf("\n");
}

return 0;
}