#include using namespace std; using Taplis = tuple< int, int, int, int >; template< class T > struct BinaryIndexedTreeReversed { vector< T > data; BinaryIndexedTreeReversed(int sz) { data.assign(++sz, -1); } T sum(int k) { T ret = -1; 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; for(int i = 0; i < N; i++) { int p, t, r; scanf("%d %d %d", &p, &t, &r); tap.emplace_back(p, t, r, i); } sort(begin(tap), end(tap)); reverse(begin(tap), end(tap)); vector< int > ord; BinaryIndexedTreeReversed< int > bit(10001); for(auto &p : tap) { int t, r, idx; tie(ignore, 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); }