public class exchange {
	public static String nacistRadku(int maximalniDelka){
		byte pole[] = new byte[maximalniDelka];
		int pozice =  0;
		int znak = -1;
		try{
			while (pozice < maximalniDelka){
				znak = System.in.read();
				if((znak<0) || (znak == '\n')) {
					break;
				}
				pole[pozice] += znak;
				pozice++;
			}
		} catch (Exception e){
			return null;
		}
		if ((znak < 0) && (pozice == 0)){
			return null;
		}
		return (new String(pole,0,pozice));
	}
	
	static int l = 30;
	
		public static void main(String[] args) {
			String end = "0 END";
			String line;
			while(true) {
				line = nacistRadku(l);
				if(line.equals(end)) {
					break;
				}
				process(line);
				if(line.equals(end)) {
					break;
				}
			}
			
			
		}
		
		static void process(String ml) {
			String[] xx = ml.split(" ");
			int count= Integer.parseInt(xx[0]);
			boolean[] buy = new boolean[count];
			String[] names = new String[count];
			int[] prices = new int[count];
			System.out.println(xx[1]);
			for(int i=0; i<count; i++) {
				String line = nacistRadku(l);
				xx = line.split(" ");
				names[i] = xx[0];
				buy[i] = xx[1].equals("buy");
				prices[i] = Integer.parseInt(xx[2].replace(".", "").replace(",", ""));
				if(buy[i]==false) {
					prices[i] = -prices[i];
				}
			}
			int fit = 0;
			for(int i=0; i<count; i++) {
				System.out.print(names[i]+":");
				fit = 0;
				for(int j=0; j<count; j++) {
					if(i==j) {
						continue;
					}
					if(buy[i]!=buy[j] && prices[i]+prices[j]>=0) {
						fit++;
						System.out.print(" "+names[j]);
					}
				}
				if(fit==0) {
					System.out.print(" NO-ONE");
				}
				System.out.println();
			}
			
		}
		
}