import java.io.*; import java.util.*; import java.lang.*; import static java.lang.System.out; public class exchange { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer pstk = new StringTokenizer(""); static String pline; public static void main(String[] args)throws Exception { /*String line; StringTokenizer stk; line = br.readLine(); //compareTo("end")!0 stk = new StringTokenizer(line); stk.nextToken(line);*/ while (akcie() >= 0); } public enum Smer { buy, sell } public static class Buyer { public String name; //public Smer smer; public double castka; ArrayList l; public Buyer() { l = new ArrayList(); } } public static int akcie() throws Exception { int n = readInt(); String name = readToken(); if (name.compareTo("END") == 0) return -1; ArrayList listb = new ArrayList(); ArrayList lists = new ArrayList(); ArrayList listall = new ArrayList(); for (int i = 0; i < n; i++) { Buyer b = new Buyer(); b.name = readToken(); String smer = readToken(); b.castka = Double.parseDouble( readToken() ); if (smer.compareTo("buy") == 0) { listb.add(b); } else { lists.add(b); } listall.add(b); } for (Buyer b: listb) { for (Buyer s: lists) { if (b.castka >= s.castka) { b.l.add(s); s.l.add(b); } } } out.println(name); for (Buyer c: listall) { out.print(c.name + ":"); if (c.l.size() == 0) { out.println(" NO-ONE"); } else { for (Buyer d: c.l) { out.print(" " + d.name); } out.println(); } } return n; } public static int readInt() throws Exception { return Integer.parseInt(readToken()); } public static String readToken() throws Exception { while (!pstk.hasMoreTokens()) pstk = new StringTokenizer(pline = br.readLine()); return pstk.nextToken(); } }