import java.io.*; import java.util.*; class person { public String name; public float price; public boolean seller; public person(String name, float price, boolean seller) { this.name = name; this.price = price; this.seller = seller; } } class issuer { public String name; public ArrayList persons; public issuer(String name) { this.name = name; persons = new ArrayList(); } public void iCompare() { System.out.println(this.name); for(person s : persons){ String out = ""; for(person s1 : persons){ if(s.seller){ if (!s1.seller) { if(s1.price >= s.price){ out += " " + s1.name; } } }else{ if (s1.seller) { if(s1.price <= s.price){ out += " " + s1.name; } } } } if (out.compareTo("") == 0) out = " NO-ONE"; System.out.println(s.name + ":" + out); } } } public class exchange { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line1; while ((line1 = br.readLine()) != null) { if (line1.indexOf("END") > 0) { break; } String s2[] = line1.split(" "); int count = Integer.parseInt(s2[0]); issuer is = new issuer(s2[1]); 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], Float.parseFloat(p[2]), false); } else { per = new person(p[0], Float.parseFloat(p[2]), true); } is.persons.add(per); } /*for (person p : is.persons) { System.out.println(p.name); }*/ is.iCompare(); } } catch (IOException e) { System.out.println("sdfsd"); } } }