#include #include #include #include //#include #include #include #include #include #include //#include #include #include #include //#include #include //#include #include #include #include #include #include const int dx[] = {1, 0, -1, 0}; const int dy[] = {0, -1, 0, 1}; using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector vi; typedef vector vll; typedef pair pii; const int MAXM = 111; struct Score { int id; int solve; int penalty; Score() {} Score(int id, int solve, int penalty) : id(id), solve(solve), penalty(penalty) {} bool operator<(const Score& rhs) const { if (solve != rhs.solve) return solve > rhs.solve; return penalty < rhs.penalty; } }; struct STP { int solve; int team; int penalty; STP() {} STP(int solve, int team, int penalty) : solve(solve), team(team), penalty(penalty) {} bool operator<(const STP& rhs) const { if (solve != rhs.solve) return solve < rhs.solve; if (team != rhs.team) return team > rhs.team; return penalty > rhs.penalty; } }; vector univ[MAXM]; int now[MAXM]; const int INF = 1e9; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; assert(1 <= N && N <= 100000 && 1 <= K && K <= N); for (int i = 0; i < N; i++) { int s, p, u; cin >> s >> p >> u; assert(0 <= s && s <= 10 && 0 <= p && p <= 1000000 && 1 <= u && u <= 100); univ[u].emplace_back(i, s, p); } for (int i = 0; i < MAXM; i++) sort(univ[i].begin(), univ[i].end()); vector ans; for (int i = 0; i < K; i++) { STP best(0, INF, INF); int index = -1; for (int j = 0; j < MAXM; j++) { if (now[j] == univ[j].size()) continue; STP tmp(univ[j][now[j]].solve, now[j], univ[j][now[j]].penalty); if (best < tmp) { best = tmp; index = j; } } assert(index != -1); ans.push_back(univ[index][now[index]].id); now[index]++; } for (int el : ans) cout << el << endl; return 0; }