import java.io.*;

public class exchange{



static int a;
static String in;
static String pole[][];
static String name;
static String data[];
static int b;
static int s;

static int flag;

	public static void main(String args[]){
         try{
 	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


//nacteni 

        while(!(in = br.readLine()).equals("0 END")){
                  
 		data = in.split(" ");
		name = data[1];
                a = Integer.parseInt(data[0]);
		pole = new String [a][3];
             

                for(int i = 0; i < a; i++) {
		
 		in = br.readLine();
		data = in.split(" ");
			
			for(int j=0; j < 3; j++){
                              pole[i][j] = data[j];
		 	}								 
		}	


		System.out.println(name);


                for(int i = 0; i < a;i++){

		String out = "";
 
                   if(pole[i][1].equals("buy")) flag = 1;
                   if(pole[i][1].equals("sell")) flag = 2;
                    

                	for(int j = 0; j < a; j++) {
                        	if (i == j) continue;
                                
 		                if(flag == 1){
					if(pole[j][1].equals("sell")) {
						if((Double.parseDouble(pole[i][2])) >= (Double.parseDouble(pole[j]	[2])))	{
	out += " " + pole[j][0];				
					}}}


				if(flag == 2){
					if(pole[j][1].equals("buy")) {
						if((Double.parseDouble(pole[i][2])) <= (Double.parseDouble(pole[j]	[2])))	{
	out += " " + pole[j][0];				
					}
					
					}
 
                        	}     
			}  
			if(out.equals(""))out = "NO-ONE";            
			
		 	System.out.println(pole[i][0] + ":" + out);	
                }

}	
}
	catch(IOException e){}
}
}
