type Nabidka = record
               Prize:real;
	       Name:string[20];
	       buy:boolean;
	       index:longint;
	       end;
var N:longint;
    i,j,k:longint;
    name:string[20];
    Nab:array[1..10000] of Nabidka;
    s:string;
    Poradi:array[1..10000] of longint;
    Pr:array[1..10000] of longint;
    MaxB,MaxS:longint;
    Num:longint;
function readZTString:string;
var c:char;
    s:string;
begin
   read(c);s:='';
   while (c=' ') do read(c);
   while (c<>' ') and (not eof(input)) do begin
      s:=s+c;
      read(c);
   end;
readZTString:=s;
end;
procedure QSort(L,R:longint);
var swap:longint;
    P:real;
    LPos,RPos:longint;
begin
   if (L >= R) then exit;
   if (L = R-1) then begin
      if (Nab[Poradi[L]].Prize > Nab[Poradi[R]].Prize) then begin
         swaP:=Poradi[L];
	 Poradi[L]:=Poradi[R];
	 Poradi[R]:=swap;
      end;
      exit;
   end;
   Lpos:=L;RPos:=R;P:=Nab[Poradi[(L + R) div 2]].Prize;
{   writeln(Nab[1].Prize);}
   while (Nab[Poradi[LPos]].Prize < p) do inc(Lpos);
{   writeln('Lpos',LPos,'P',P:10:3);}
   while (Nab[Poradi[RPos]].Prize > p) do dec(RPos);
{   writeln('LPos:',Lpos,'RPos',RPos);}
   while (LPos < RPos) do begin
      Swap:=Poradi[LPos];
      Poradi[Lpos]:=Poradi[RPos];
      Poradi[Rpos]:=Swap;
      inc(Lpos);
      dec(RPos);
      if (LPos<RPos) then begin
         while (Nab[Poradi[Lpos]].Prize < p) do inc(LPos);
	 while (Nab[Poradi[RPos]].Prize > p) do dec(RPos);
      end;
   end;
   QSort(L,RPos);
   QSort(LPos,R);
end;
function noend(s:string):boolean;
begin
   noend:=(s<>'END');
end;
begin
   read(N);
   name:=ReadZTString;
   readln;
   while (N<>0) and (noend(name)) do begin
      for i:=1 to N do begin
         Nab[i].Name:=readZTString;
	 s:=readZTString;
	 readln(Nab[i].Prize);
	 Nab[i].Buy := (s[1]='b');
	 if (Nab[i].Buy = FALSE) then Nab[i].Prize:=Nab[i].Prize - 0.0001;
	 Poradi[i]:=i;
	 Pr[i]:=-4;
      end;
{      QSort(1,N);}
{      MaxB:=-1;MaxS:=-1;
      for i:=1 to N do begin
      writeln(i,'/',Poradi[i],'/',Nab[Poradi[i]].Prize:4:4,'/',MaxS,',',MaxB);
         if Nab[Poradi[i]].buy then begin
	    MaxB:=i;
	    Nab[Poradi[i]].index:=MaxS;
	 end else begin
	    Pr[i]:=MaxS;
	    MaxS:=i;
	 end;
      end;
      for i:=1 to N do write(Pr[i],'/');
      writeln;
      MaxB:=-1;MaxS:=-1;
      for i:=N downto 1 do begin
      for k:=1 to N do write(Pr[k],'/');
      writeln(';',MaxB,'/',MaxS);
         if (Nab[Poradi[i]].buy) then begin
	    Pr[i]:=MaxB;
	    MaxB:=i;
	 end else begin
	    MaxS:=i;
	    Nab[Poradi[i]].index:=MaxB;
	 end;
      end;}
      writeln(name);
{      for i:=1 to N do write(Pr[i],'/');
      writeln;}
      for i:=1 to N do begin
         write(Nab[i].name,':');
{	 j:=Nab[i].index;
	 if (j = -1) then 
	    write(' NO-ONE')
	 else
	    while (j<>-1) do begin
	       write(' ',Nab[Poradi[j]].Name);
	       j:=Pr[j];
	    end;}
	 Num:=0;
	 if (Nab[i].buy) then begin
	    for k:=1 to N do if ((Nab[i].Prize > Nab[k].Prize) and (not Nab[k].buy)) then begin
	       inc(Num);
	       write(' ',Nab[k].Name);
	    end;
	 end else begin
	    for k:=1 to N do if ((Nab[i].Prize < Nab[k].Prize) and (Nab[k].buy)) then begin
	       inc(Num);
	       write(' ',Nab[k].Name);
	    end;
	 end;
	 if (Num = 0) then write(' NO-ONE');
	 writeln;
      end;
      read(N);
      name:=ReadZTString;
      readln;
   end;
end.