#include using namespace std; #define rep(i,n) for(long long i = 0; i < (long long)(n); i++) #define pb push_back #define all(x) (x).begin(), (x).end() #define fi first #define se second template bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); } template bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); } using ll = long long; using vll = vector; using vvll = vector; using P = pair; template struct SegmentTreeMax { int n; T inf; vector dat; SegmentTreeMax(int n_ = 0) : n(n_){ inf = numeric_limits::min(); for(n = 1; n < n_; n <<= 1); dat.resize(n*2, inf); } T query(int v, int w, int l, int r){ if(r <= l || w == 0) return inf; if(r - l == w) return dat[v]; // assert(l == 0 && r == w); int m = w/2; return max(query(v*2, m, l, min(r,m)), query(v*2+1, m, max(0,l-m), r-m)); } void update(int i, const T &x){ dat[i+=n] = x; for(; i!=1; i/=2) dat[i/2] = max(dat[i], dat[i^1]); } T query(int l, int r){ return query(1,n,l,r); } size_t size() const { return n; } T operator [] (const int &idx) { return query(idx, idx + 1); } }; int main(void) { ios::sync_with_stdio(false); cin.tie(0); SegmentTreeMax s(1e5+10); ll n; cin >> n; vector> g(1e5+10); map memo; rep(i, n) { ll x, y, z; cin >> x >> y >> z; g[x].pb(P(y, z + 1)); memo[{x, y, z + 1}] = i; } vector ret; for (ll i = g.size() - 1; i >= 0; i--) { sort(all(g[i])); reverse(all(g[i])); vector

next; for (auto x : g[i]) { if (x.se > s.query(x.fi, 1e5+10)) { next.pb(x); ret.pb({i, x.fi, x.se}); } s.update(x.fi, x.se); } } set id; for (auto x : ret) id.insert(memo[x]); for (auto x : id) cout << x + 1 << endl; return 0; }