#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int mod=1e9+7; int main(){ int n,no,m,s; string tag; mapmp; cin>>n; while(cin>>no){ cin>>m>>s; for(int i=0;i>tag; mp[tag]+=s; } } vector>vec; for(auto x:mp) vec.push_back({-x.second,x.first}); sort(vec.begin(),vec.end()); for(int i=0;i