import java.util.*;

public class exchange {
	
	public static void main (String [] args){
		boolean end = true;
		String line = null;
		String actualFirm = null;
		
		String command [];
		Scanner sc = new Scanner (System.in);
		
		List<String> firms = new ArrayList<String>();
		Map<String, Integer> map = new TreeMap<String, Integer>();
		List<String> users = new ArrayList<String>();
		Map<String, Boolean>actors = new TreeMap<String, Boolean>();
		Map<String, Double> prices = new TreeMap<String, Double>();
		
		while (end) {
			line = sc.nextLine();
			command = line.split(" ");
			
			try {
				int i = Integer.parseInt(command[0]);
				if (i == 0) {
					end = false;
					break;
				} else {
					firms.add(command[1]);
					map.put(command[1], 0);
					actualFirm = command[1];
				}
			} catch (NumberFormatException e) {
				boolean buy;
				if ("buy".equals(command[1])) {
					buy = true;
				} else {
					buy = false;
				}
				String user = command[0]+actualFirm;
				map.put(actualFirm,map.get(actualFirm)+1);
				users.add(user);
				actors.put(user, buy);
				prices.put(user, Double.parseDouble(command[2]));
			}
		}
		
		int i = 0;
		int oldI = 0;
		boolean noOne;
		for (String firm : firms) {
			int y = map.get(firm);
			System.out.println(firm);
			y=i+y;
			oldI = i;
			
			for (int x = i; x < y; x++) {
				String user = users.get(x);
				boolean buy = actors.get(user);
				Double value = prices.get(user);
				noOne = true;
				System.out.print(bezFirmy(firm,user) + ":");
				for (int a=oldI; a < y ; a++){
					String userX = users.get(a);
					boolean buyX = actors.get(userX);
					Double valueX = prices.get(userX);
					if (buy!=buyX) {
						if (buy){
							if(value >= valueX){
								System.out.print(" "+bezFirmy(firm,userX));
								noOne = false;
								}
						}
						else
						{
							if(value <= valueX){
								System.out.print(" "+bezFirmy(firm,userX));
								noOne = false;
								}
						}
					}
					
					
				}
				if (noOne)
					System.out.println(" NO-ONE");
				else
					System.out.println();
				i++;
			}
		}
	}	
	
	public static String bezFirmy (String firm, String user){
		//System.out.println(user.length() + " X ");
		//System.out.println(firm.length() + " X ");
		return user.substring(0, user.length()-firm.length());
		//return "";
		}
}