import java.util.*;

public class exchange {
	static String firma;
	static double[] ceny;
	static String []lidi;
	
	
	public static String najdiJe(int i) {
		String res = "";
		for (int j=0; j<ceny.length; j++) {
				if (i==j) continue;
				if (ceny[i]*ceny[j]>0) continue;
				if ((ceny[i]*-1)>=ceny[j]) res+=" "+lidi[j];
		}
		if (res.equals("")) res = " NO-ONE";
		return res;

		
	}
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useLocale(Locale.US);
		
		while (1 == 1) {
			int pocet = sc.nextInt();
			if (pocet==0) break;
			firma = sc.next();
			sc.nextLine();
			ceny = new double[pocet];
			lidi = new String[pocet];
			for (int i = 0; i< pocet; i++) {
				lidi[i] = sc.next();
				int k = 1;
				if ((sc.next()).equals("buy")) k=-1;
				ceny[i]=sc.nextDouble()*k;
			}
			System.out.println(firma);
			for (int i=0; i<pocet; i++) {
			System.out.println(""+ lidi[i]+ ":"+najdiJe(i));
			
			}
		}
	}
}