#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; struct Team { int id; int solve; int penalty; int univ; int sameUpper; Team() {} Team(int id, int solve, int penalty, int univ) : id(id), solve(solve), penalty(penalty), univ(univ) {} }; bool comp1(const Team& lhs, const Team& rhs) { if (lhs.solve != rhs.solve) return lhs.solve > rhs.solve; return lhs.penalty < rhs.penalty; } bool comp2(const Team& lhs, const Team& rhs) { if (lhs.solve != rhs.solve) return lhs.solve > rhs.solve; if (lhs.sameUpper != rhs.sameUpper) return lhs.sameUpper < rhs.sameUpper; return lhs.penalty < rhs.penalty; } const int MAXN = 100100; Team teams[MAXN]; int memo[MAXN]; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; set S; 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); assert(0 <= p && p <= 1000000); assert(1 <= u && u <= 100000); teams[i] = Team(i, s, p, u); S.insert(pii(s, p)); } assert(S.size() == N); sort(teams, teams+N, comp1); for (int i = 0; i < N; i++) { teams[i].sameUpper = memo[teams[i].univ]++; } sort(teams, teams+N, comp2); for (int i = 0; i < K; i++) cout << teams[i].id << endl; return 0; }