var a:array[0..5,0..3] of string[100];
    aux:byte;
    i,j,m,k:0..5;
    ok:boolean;
    s:string[100];
    v:array[0..5,0..1] of byte;
    pct:array[0..3] of byte;
    c:array[0..3] of string[100];


begin

        for i:=0 to 3 do begin
                c[i]:='';
                pct[i]:=0;
                          end;

     for i:=0 to 5 do
         for j:=0 to 3 do readln(a[i,j]);

     for i:= 0 to 5 do
         if a[i,2]=a[i,3] then begin
                                    v[i,0]:=1;
                                    v[i,1]:=1;
                                end
                           else if a[i,2]>a[i,3] then begin
                                                           v[i,0]:=3;
                                                           v[i,1]:=0;
                                                       end
                                                  else begin
                                                            v[i,0]:=0;
                                                            v[i,1]:=3;
                                                        end;

     m:=0;
     for i:=0 to 5 do
         for j:=0 to 1 do begin
             ok:=true;
             for k:=0 to 3 do
                 if c[k]=a[i,j] then ok:=false;
             if ok=true then begin inc(m); c[m]:=a[i,j]; end;
                           end;

     for i:=0 to 4 do
              for j:=0 to 5 do
                  for k:=0 to 1 do
                      if c[i]=a[j,k] then pct[i]:=pct[i]+v[j,k];

     for i:=0 to 2  do
         for j:=i+1 to 3 do
             if pct[i]<pct[j] then begin
                                        aux:=pct[i];
                                        pct[i]:=pct[j];
                                        pct[j]:=aux;
                                        s:=c[i];
                                        c[i]:=c[j];
                                        c[j]:=s;
                                    end;

     for i:=0 to 3 do writeln(c[i]);
     readln;

end.