#include #include using namespace std; typedef struct bid { string agent; bool op; // buy = true double price; }bid; bid bids[1000]; int main() { int n; string issuer, str; bool no_one; while(1) { cin >> n; cin >> issuer; if(!n && issuer == "END") break; cout << issuer << endl; for(int i = 0; i < n; ++i) { cin >> bids[i].agent; cin >> str; if(str == "buy") bids[i].op = true; else bids[i].op = false; cin >> bids[i].price; //cout << bids[i].price << endl; } for(int x = 0; x < n; ++x) { cout << bids[x].agent << ":"; no_one = true; for(int y = 0; y < n; ++y) { if(bids[x].op xor bids[y].op) { if(bids[x].op && (bids[x].price >= bids[y].price)) { cout << " " << bids[y].agent; no_one = false; } else if(!bids[x].op && (bids[x].price <= bids[y].price)) { cout << " " << bids[y].agent; no_one = false; } } } if(no_one) { cout << " NO-ONE\n"; } else { cout << endl; } } } return 0; }