#include using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i,n) for (int i=0;i<(n);i++) #define rep2(i,a,b) for (int i=(a);i<(b);i++) #define rrep(i,n) for (int i=(n)-1;i>=0;i--) #define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--) #define all(a) (a).begin(),(a).end() typedef long long ll; typedef pair Pii; typedef tuple TUPLE; typedef vector V; typedef vector VV; typedef vector VVV; typedef vector> Graph; const int inf = 1e9; const int mod = 1e9 + 7; struct Data { int id_team, id_univ; int ac, ue, pena; Data(){} Data(int _id_team, int _id_univ, int _ac, int _ue, int _pena) : id_team(_id_team), id_univ(_id_univ), ac(_ac), ue(_ue), pena(_pena) {} bool operator<(const Data& r) const { return ac == r.ac ? (ue == r.ue ? pena < r.pena : ue < r.ue) : ac > r.ac; } void print() { cerr << id_team << " " << id_univ << " " << ac << " " << ue << " " << pena << endl; } }; signed main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int N, K; cin >> N >> K; vector teams; rep(i, N) { int s, p, u; cin >> s >> p >> u; teams.emplace_back(i, u, s, 0, p); } sort(all(teams)); int cnt_ue[101] = {}; rep(i, N) { teams[i].ue = cnt_ue[teams[i].id_univ]; ++cnt_ue[teams[i].id_univ]; } sort(all(teams)); rep(i, K) { cout << teams[i].id_team << endl; } }