#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef vector VI; typedef vector VVI; typedef vector VS; typedef pair PII; typedef long long LL; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define MP make_pair #define MT make_tuple #define EACH(i,c) for(auto i: c) #define SORT(c) sort((c).begin(),(c).end()) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() int main() { int N, K; cin >> N >> K; vector>>> M(11); REP(i, N){ int s, p, u; scanf("%d %d %d", &s, &p, &u); M[s][0][u].push(MP(-p, i)); //cout << M[s][0].size() << endl; } int i = 10; while(K--){ int best = 100000000, u = -1; REP(j, 11){ EACH(m, M[i][j]){ //cout << j << " u : " << m.first << " " << m.second.empty() << endl; if(m.second.empty()) continue; PII tmp = m.second.top(); //cout << tmp.first << " " << tmp.second << endl; if(tmp.first < best){ best = tmp.first; u = m.first; } } if(u >= 0){ PII tmp = M[i][j][u].top(); printf("%d\n", tmp.second); M[i][j][u].pop(); swap(M[i][j + 1][u], M[i][j][u]); break; } } if(u < 0){ K++; i--; } } return 0; }