#include using namespace std; #define REP(i,n) for(int i=0;i ostream& operator<<(ostream& os,const vector& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; } typedef long long ll; typedef unsigned long long ull; typedef pair pii; typedef vector vi; typedef vector vvi; constexpr ll mod = 1e9+7; #define UNIV_MAX 100010 int main(){ using P4 = tuple; using P3 = tuple; int n,k; cin>>n>>k; vector> Univ(UNIV_MAX); rep(i,n){ int s,p,u;cin>>s>>p>>u; Univ[u].push_back(P3(s,-p,i)); } priority_queue que; rep(i,UNIV_MAX+1) if(Univ[i].size()){ sort(all(Univ[i])); reverse(all(Univ[i])); for(int j=0;j