program exchange;


var i,j,d,n,kolko:longint;
    r:string;
    nazov,uloha:array[0..1001]of string;
    hod:array[0..1001]of extended;
    code:integer;
 
begin
     readln(r);
     while r<>'0 END' do
     begin
          d:=pos(' ',r);
          val(copy(r,1,d-1),n,code);
          delete(r,1,d);
          writeln(r);
          for i:=1 to n do
          begin
               readln(r);
               d:=pos(' ',r);
               nazov[i]:=copy(r,1,d-1);
               delete(r,1,d);
               d:=pos(' ',r);
               uloha[i]:=copy(r,1,d-1);
               delete(r,1,d);
               val(r,hod[i],code);
          end; 
          for i:=1 to n do
          begin
               write(nazov[i],':');
               
               if uloha[i]='buy' then 
               begin
                    kolko:=0;
                    for j:=1 to n do if uloha[j]='sell' then if (hod[i]>=hod[j]) then kolko:=kolko+1;
                    if kolko=0 then writeln('NO-ONE') else
                    begin
                         for j:=1 to n do if uloha[j]='sell' then if (hod[i]>=hod[j]) then write(' ',nazov[j]);
                    end;
               end
               else
               begin
                    kolko:=0;
                    for j:=1 to n do if uloha[j]='buy' then if (hod[i]<=hod[i]) then kolko:=kolko+1;
                    if kolko=0 then writeln('NO-ONE') else
                    begin
                         for j:=1 to n do if uloha[j]='buy' then if (hod[i]<=hod[j]) then write(' ',nazov[j]); 
                    end;
               end;
          end;
          readln(r);
     end;
end. 
