#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; using ull = unsigned long long; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int q; cin >> q; map mp; while(q--){ int id; cin >> id; int n; cin >> n; int s; cin >> s; for(int i=0;i> t; mp[t]+=s; } } vector> v; for(auto p:mp){ v.push_back(make_pair(-p.second,p.first)); } sort(v.begin(), v.end()); for(int i=0;i