import java.util.*; import java.io.*; import java.lang.Math; public class exchange { public static void main(String[] args) throws Exception { new exchange().run(); } private void run() throws Exception { int n; while ((n = nextInt()) != 0) { String[] names = new String[n]; int[] types = new int[n]; double[] bits = new double[n]; String[] results = new String[n]; String code = nextToken(); for (int i = 0; i < n; i++) { results[i] = ""; } for (int i = 0; i < n; i++) { String name = nextToken(); String type = nextToken(); double bit = nextDouble(); if (type.charAt(0) == 'b') { names[i] = name; types[i] = BUY; bits[i] = bit; } if (type.charAt(0) == 's') { names[i] = name; types[i] = SELL; bits[i] = bit; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if ((types[i] != types[j])) { if (types[i] == BUY) { if (bits[i] >= bits[j]) results[i] += names[j] + " "; } if (types[i] == SELL) { if (bits[i] <= bits[j]) results[i] += names[j] + " "; } } } } for (int i = 0; i < n; i++) { if (results[i] == "") results[i] = "NO-ONE"; } System.out.println(code); for (int i = 0; i < n; i++) { System.out.println(names[i] + ": " + results[i]); } } } final int BUY = 1; final int SELL = 2; StringTokenizer st = new StringTokenizer(""); BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String nextToken() throws Exception { while (!st.hasMoreTokens()) st = new StringTokenizer(input.readLine()); return st.nextToken(); } int nextInt() throws Exception { return Integer.parseInt(nextToken()); } double nextDouble() throws Exception { return Double.parseDouble(nextToken()); } long mocnina(int zaklad, int exp) { if (exp > 0) return zaklad * mocnina(zaklad, exp -1); else return 1; } }