#include using namespace std; using Taplis = tuple< int, int, int >; template< class T > struct BinaryIndexedTreeReversed { vector< T > data; BinaryIndexedTreeReversed(int sz) { data.assign(++sz, -1); } T sum(int k) { T ret = 0; for(++k; k < data.size(); k += k & -k) ret = max(ret, data[k]); return (ret); } void add(int k, T x) { for(++k; k > 0; k -= k & -k) data[k] = max(data[k], x); } }; int main() { int N; scanf("%d", &N); vector< Taplis > tap[10001]; for(int i = 0; i < N; i++) { int p, t, r; scanf("%d %d %d", &p, &t, &r); tap[p].emplace_back(t, r, i); } // T[i]<=T[j]かつR[i]<=R[j]のものが存在するか vector< int > ord; BinaryIndexedTreeReversed< int > bit(10001); for(int i = 10000; i >= 0; i--) { sort(begin(tap[i]), end(tap[i])); reverse(begin(tap[i]), end(tap[i])); int ret = 0; for(auto &p : tap[i]) { int t, r, idx; tie(t, r, idx) = p; if(bit.sum(t) <= r) ord.push_back(idx); bit.add(t, r); } } sort(begin(ord), end(ord)); for(auto &p : ord) printf("%d\n", p + 1); }