#include<iostream>
//#include<fstream>
#include<queue>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>

using namespace std;

//ifstream cin("date.in");
//ofstream cout("date.out");

int n,i,j,a1,b1,sc,s1,s2,scor[10],gls[10],v[10];
char aux,c[10][1000],a[1000],b[1000];

bool cmp(int a, int b){
    if(scor[a]==scor[b]){
        if(gls[a]==gls[b]){
            if(strcmp(c[a],c[b])>0){
                return 1;
            }
            return 0;
        }
        return gls[a]<gls[b];
    }
    return scor[a]<scor[b];
}

int main(){
    for(i=1;i<=6;i++){
        cin>>a>>b>>s1>>s2;
        a1=0;
        b1=0;
        for(j=0;j<n;j++){
            if(strcmp(a,c[j])==0){
                a1=1;
            }
            if(strcmp(b,c[j])==0){
                b1=1;
            }
        }
        if(!a1){
            strcpy(c[n],a);
            n++;
        }
        if(!b1){
            strcpy(c[n],b);
            n++;
        }
        sc=0;
        if(s1==s2){
            sc=1;
        }
        if(s1>s2){
            sc=2;
        }
        for(j=0;j<n;j++){
            if(strcmp(a,c[j])==0){
                if(sc==1){
                    scor[j]++;
                }else if(sc==2){
                    scor[j]+=3;
                    gls[j]+=s1;
                }
            }
            if(strcmp(b,c[j])==0){
                if(sc==1){
                    scor[j]++;
                }else if(sc==0){
                    scor[j]+=3;
                    gls[j]+=s2;
                }
            }
        }

    }
    v[0]=0;
    v[1]=1;
    v[2]=2;
    v[3]=3;
    sort(v,v+4,cmp);
    for(i=3;i>=0;i--){
        cout<<c[v[i]]<<'\n';
    }

    return 0;
}