import java.io.*; class person { public String name; public double price; public boolean seller; public person(String name, double price, boolean seller) { this.name = name; this.price = price; this.seller = seller; } } class issuer { public String name; public person[] persons; public issuer(String name, int n) { this.name = name; persons = new person[n]; } public void iCompare() { System.out.println(this.name); for(int i =0; i < persons.length; i++){ String out = ""; for(int k = 0; k< persons.length; k++){ if(persons[i].seller){ if (!persons[k].seller) { if(persons[k].price >= persons[i].price){ out += " " + persons[k].name; } } }else{ if (persons[k].seller) { if(persons[k].price <= persons[i].price){ out += " " + persons[k].name; } } } } if (out.compareTo("") == 0) out = " NO-ONE"; System.out.println(persons[i].name + ":" + out); } } } public class exchange { public static void main(String[] args) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line1; try { while ((line1 = br.readLine()) != null) { if (line1.compareTo("O END") == 0) break; String s2[] = line1.split(" "); int count = Integer.parseInt(s2[0]); issuer is = new issuer(s2[1], count); for (int i = 0; i < count; i++) { String l2 = br.readLine(); String p[] = l2.split(" "); person per; if (p[1].compareTo("buy") == 0) { per = new person(p[0], Double.parseDouble(p[2]), false); } else { per = new person(p[0], Double.parseDouble(p[2]), true); } is.persons[i]= per; } is.iCompare(); } } catch (IOException e) { } return; } }