#include using namespace std; using ll = long long; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define all(x) (x).begin(),(x).end() #define pb push_back #define fi first #define se second #define dbg(x) cout<<#x" = "<<((x))< ostream& operator<<(ostream& o, const pair &p){o<<"("< ostream& operator<<(ostream& o, const vector &v){o<<"[";for(T t:v){o<; int main(){ int n; cin >>n; map p; rep(i,n){ int no,m,s; cin >>no >>m >>s; while(m--){ string t; cin >>t; p[t] += s; } } vector

v; for(const auto &x:p) v.pb({-x.se,x.fi}); sort(all(v)); int V=v.size(); rep(i,min(10,V)) cout << v[i].se << " " << -v[i].fi << endl; return 0; }