#include using namespace std; using ll = long long; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b(const Tag &another) const { if(score == another.score){ // return name > another.name; return name < another.name; }else{ return score > another.score; } } string ToString(){ stringstream ss; ss << name << ' ' << score; return ss.str(); } }; int main(){ cin.tie(0); ios::sync_with_stdio(false); // input ll N; cin >> N; map mp; while(N--){ ll id; cin >> id; ll num, score; cin >> num >> score; FOR(i, 0, num){ string tag; cin >> tag; mp[tag] += score; } } vector T; for(auto p : mp){ T.push_back(Tag(p.first, p.second)); } sort(ALL(T), greater()); ll count = 0; for(auto t : T){ p(t.ToString()); count++; if(count==10) return 0; } return 0; }