#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
int i,x,y,t;
string a,b,e[10];
map<string,int> m,g;
bool sortare(string a,string b)
{
    return (m[a]>m[b]||(m[a]==m[b]&&g[a]>g[b])||(m[a]==m[b]&&g[a]==g[b]&&a<b));
}
int main()
{
    for (i=1;i<=6;i++)
    {
        cin>>a>>b>>x>>y;
        if (!m.count(a)) {m[a]=0; e[++t]=a;g[a]=0;}
        if (!m.count(b)) {m[b]=0; e[++t]=b;g[b]=0;}
        if (x>y) m[a]+=3;
        else if (x<y) m[b]+=3;
        else {m[a]++; m[b]++;}
        g[a]+=x;
        g[b]+=y;
    }
    sort(e+1,e+4,sortare);
    for (i=1;i<=4;i++)
        cout<<e[i]<<'\n';
    return 0;
}