
import java.io.*;
import java.util.*;
public class exchange 
{
  public static void main( String[] args ) throws Exception
  {
    BufferedReader bf = new BufferedReader( new InputStreamReader( System.in ) );
    while ( true )
    {
    String line1 = bf.readLine();
    StringTokenizer st = new StringTokenizer( line1, " ");
    String pocet = st.nextToken();
    String jmeno_firmy = st.nextToken();


    int pocet_ak = Integer.parseInt( pocet );

    if ( pocet_ak == 0 && jmeno_firmy.equals( "END" ) )
    {
    	break;
    }
    ArrayList<akter> akt = new ArrayList<akter>();
    System.out.print( jmeno_firmy + "\n");
    for ( int i = 0; i < pocet_ak; i++ )
    {
	line1 = bf.readLine();
	st = new StringTokenizer( line1, " " );
	akt.add( new akter( st.nextToken(), st.nextToken(), st.nextToken() ) );
    }
    for ( akter a : akt )
    {
 	int poc = 0;
    	System.out.print( a.jmeno + ":");
    	for ( akter b: akt )
	{
	  if ( a.akce == 0 && b.akce == 1 )
	  {
	  	if ( a.cena<=b.cena){
			System.out.print( " " +b.jmeno );	
			poc++;
		}
	  }
	  if ( a.akce == 1 && b.akce == 0 )
	  {
	  	if ( a.cena>=b.cena){
			System.out.print( " " + b.jmeno );
			poc++;
		}
	  }
	}
	if(poc==0){
		System.out.print(" NO-ONE");
	}

    	System.out.println();
    }
    }//end while
}
}
class akter
{
	public String jmeno;
	public int akce;
	public double cena;

	public akter( String jmeno, String akce, String cena )
	{
		this.jmeno = jmeno;
		if ( akce.equals( "buy" ) ) this.akce = 1;
		else if ( akce.equals( "sell" ) ) this.akce = 0;
		this.cena = Double.parseDouble( cena );
	}
}
