#include using namespace std; struct Team{ int idx; int s; int p; int u; int uidx; Team() {} Team(int idx, int s, int p, int u) : idx(idx),s(s), p(p), u(u) {} }; int N, K; vector teams(100001); map> univ; int main(){ cin >> N >> K; for(int i = 0; i < N; i++){ int s, p, u; cin >> s >> p >> u; Team t(i, s, p, u); teams[i] = t; univ[u].push_back(i); } for(auto& uu : univ){ sort(uu.second.begin(), uu.second.end(), [] (const int& a, const int& b) -> bool { if(teams[a].s != teams[b].s) return teams[b].s < teams[a].s; else return teams[a].p < teams[b].p; }); for(int i = 0; i < uu.second.size(); i++){ teams[i].uidx = i; } } sort(teams.begin(), teams.end(), [] (const Team& a, const Team& b) -> bool { if(a.s != b.s) return b.s < a.s; else if(a.uidx != b.uidx) return a.uidx < b.uidx; else return a.p < b.p; }); for(int i = 0; i < K; i++){ cout << teams[i].idx << endl; } }