#include <iostream>
#include <string.h>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef struct
{
    char team[100];
    int gols;
    int scor;
}A;
A v[10];

bool CMP(A ter1,A ter2)
{
    if(ter1.scor>ter2.scor)return 1;
    else if(ter1.scor==ter2.scor&&ter1.gols>ter2.gols)return 1;
    return 0;
}

int x,y,q,w;
char a[100],b[100];
int main()
{
    //freopen("input.in","r",stdin);
    for(int i=1;i<=6;++i)
    {
        cin>>a>>b>>x>>y;
        //scanf("%s %s %d %d",&a,&b,&x,&y);
        if(i==1)
        {
            q=1;w=2;
            strcpy(v[1].team,a);
            strcpy(v[2].team,b);
        }
        else if(i==2)
        {
            q=3;w=4;
            strcpy(v[3].team,a);
            strcpy(v[4].team,b);
        }
        else
        {
            for(int j=1;j<=4;++j)
            {
                if(strcmp(v[j].team,a)==0)q=j;
                if(strcmp(v[j].team,b)==0)w=j;
            }
        }
        if(x>y)v[q].scor+=3;
        else if(x<y)v[w].scor+=3;
        else
        {
            v[q].scor+=1;
            v[w].scor+=1;
        }
        v[q].gols+=x;
        v[w].gols+=y;
    }
    sort(v+1,v+5,CMP);
    for(int i=1;i<=4;++i)
    {
        cout<<v[i].team<<'\n';
    }
    return 0;
}