program tournament;
type mat=record
        nu:string; sc:byte;
        end;
var v:array[1..6] of mat;
    s,sa,s1:string; i,j,k,p1,p2,poz1,poz2,aux:byte; este,sortat:boolean; er1,er2:integer;

begin
j:=0;
for i:=1 to 6 do
        begin
        readln(s);

        s1:=copy(s,1,pos(s,' ')-1); delete(s,1,pos(s,' '));
        este:=false;
        for k:=1 to j do if v[k].nu=s1 then begin poz1:=j; este:=true; end;
        if not este then begin inc(j); v[j].nu:=s1; poz1:=j; end;

        s1:=copy(s,1,pos(s,' ')-1); delete(s,1,pos(s,' '));
        este:=false;
        for k:=1 to j do if v[k].nu=s1 then begin poz2:=j; este:=true; end;
        if not este then begin inc(j); v[j].nu:=s1; poz2:=j; end;
        s1:=s[1]; delete(s,1,2); val(s1,p1,er1); val(s,p2,er2);

        if p1=p2 then begin inc(v[poz1].sc); inc(v[poz2].sc); end
                 else if p1<p2 then v[poz2].sc:=v[poz2].sc+3
                               else v[poz1].sc:=v[poz1].sc+3;
        end;

repeat sortat:=false;
for i:=1 to 3 do
        if v[i].nu>v[i+1].nu then begin
        aux:=v[i].sc; v[i].sc:=v[i+1].sc; v[i+1].sc:=aux; sortat:=false;
        sa:=v[i].nu; v[i].nu:=v[i+1].nu; v[i+1].nu:=sa;
        end;
until sortat;

repeat sortat:=false;
for i:=1 to 3 do
        if v[i].sc<v[i+1].sc then begin
        aux:=v[i].sc; v[i].sc:=v[i+1].sc; v[i+1].sc:=aux; sortat:=false;
        sa:=v[i].nu; v[i].nu:=v[i+1].nu; v[i+1].nu:=sa;
        end;
until sortat;

for i:=1 to 4 do writeln(v[i].nu);
end.