#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <map>

#define INF (1<<30)
#define mod 666013

using namespace std;
struct group
{
    char t[1005];
    int p, g;
}a[6], aux;
int x, y, i, j, o, k, t, q, r;
char s[1005], t1[1005], t2[1005];
int cmp(char a[1005], char b[1005])
{
    int i=1;
    while(a[i]==b[i]&&i<=101) i++;
    if(a[i]==b[i]) return 0;
    if(a[i]>b[i]) return 1;
    return -1;
}
bool C(group a, group b)
{
    if(a.p==b.p)
    {
        if(a.g==b.g)
        {
            int x=cmp(a.t, b.t);
            if(x<0) return 1;
            return 0;
        }
        return a.g>b.g;
    }
    return a.p>b.p;
}
int main()
{
    //freopen("1.in", "r", stdin);
    //freopen("1.out", "w", stdout);
    t=6;
    q=0;
    while(t--)
    {
        gets(s+1);
        i=1;
        while((s[i]>='A'&&s[i]<='Z')||(s[i]>='a'&&s[i]<='z'))
        {
            t1[i]=s[i];
            i++;
        }
        t1[i]=0;
        i++;
        j=1;
        while((s[i]>='A'&&s[i]<='Z')||(s[i]>='a'&&s[i]<='z'))
        {
            t2[j]=s[i];
            i++;j++;
        }
        x=0;
        t2[j]=0;
        i++;
        while(s[i]>='0'&&s[i]<='9')
            x=x*10+s[i]-'0', i++;
        i++;
        y=0;
        while(s[i]>='0'&&s[i]<='9')
            y=y*10+s[i]-'0', i++;
        o=0;
        for(i=1;i<=q;i++)
        {
            r=cmp(a[i].t, t1);
            if(r==0)
            {
                o=i;
                break;
            }
        }
        if(o==0)
        {
            q++;
            strcpy(a[q].t+1, t1+1);
            o=q;
        }
        k=0;
        for(i=1;i<=q;i++)
        {
            r=cmp(a[i].t, t2);
            if(r==0)
            {
                k=i;
                break;
            }
        }
        if(k==0)
        {
            q++;
            strcpy(a[q].t+1, t2+1);
            k=q;
        }
        a[o].g+=x;
        a[k].g+=y;
        if(x>y)
            a[o].p+=3;
        if(x<y)
            a[k].p+=3;
        if(x==y)
        {
            a[k].p++;
            a[o].p++;
        }
    }
    for(i=1;i<4;i++)
        for(j=i+1;j<=4;j++)
        {
            if(a[j].p>a[i].p)
            {
                aux=a[j];
                a[j]=a[i];
                a[i]=aux;
            }
            else if(a[j].p==a[i].p)
            {
                if(a[j].g>a[i].g)
                {
                    aux=a[j];
                    a[j]=a[i];
                    a[i]=aux;
                }
                else if(a[j].g==a[i].g)
                {
                    x=cmp(a[j].t, a[i].t);
                    if(x<0)
                    {
                        aux=a[j];
                        a[j]=a[i];
                        a[i]=aux;
                    }
                }
            }
        }
    for(i=1;i<=4;i++)
        printf("%s\n", a[i].t+1);
    return 0;
}