#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
char a[100],b[100];
int nre,Ga,Gb;
struct T{char name[100]; int pct;} team[10];
void adaug(char name[],int pct)
{
    for(int i=1;i<=nre;i++)
        if(strcmp(team[i].name,name)==0)
            {team[i].pct+=pct; return;}
    strcpy(team[++nre].name,name);
    team[nre].pct=pct;
}
bool test(T x,T y)
{
    if(x.pct>y.pct) return true;
    else
        if(x.pct<y.pct) return false;
        else
            if(strcmp(x.name,y.name)<=0)    return 1;
            else return 0;
}
int main()
{
    for(int i=1;i<=6;i++)
    {
        cin>>a;
        cin>>b;
        cin>>Ga>>Gb;
        cin.get();
        if(Ga>Gb) Ga=3,Gb=0;
        else
            if(Ga==Gb) Ga=1,Gb=1;
            else Ga=0,Gb=3;
        adaug(a,Ga);
        adaug(b,Gb);
    }
    sort(team+1,team+nre+1,test);
    for(int i=1;i<=4;i++)
        cout<<team[i].name<<'\n';
    return 0;
}