#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef pair pii; typedef pair pll; typedef int _loop_int; #define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i) #define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i) #define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i) #define DEBUG(x) cout<<#x<<": "< P; int main(){ int n; cin>>n; map cnt; while(n--){ int m,s; cin>>m; cin>>m>>s; while(m--){ string x; cin>>x; cnt[x] += s; } } vector v; for(auto P : cnt){ v.push_back(P.first); } sort(ALL(v), [&](string a,string b){ if(cnt[a] != cnt[b])return cnt[a] > cnt[b]; return a < b; }); n = min(10, (int)v.size()); REP(i,n)cout<