// includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // macros #define ll long long int #define pb emplace_back #define mk make_pair #define pq priority_queue #define FOR(i, a, b) for(int i=(a);i<(b);++i) #define rep(i, n) FOR(i, 0, n) #define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--) #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) using namespace std; // types typedef pair P; typedef pair Pl; typedef pair Pll; typedef pair Pd; // constants const int inf = 1e9; const ll linf = 1LL << 50; const double EPS = 1e-10; const int mod = 1e9 + 7; // solve template bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;} template bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;} template struct SegmentTree_ { function f; function g; int n; T def; vector vec; SegmentTree_(){} SegmentTree_(int n_, function f_, function g_, T def_, vector v=vector()){ f = f_; g = g_; def = def_; // initialize vector n = 1; while(n < n_){ n *= 2; } vec = vector(2*n -1, def); // initialize segment tree for(int i = 0; i < v.size(); i++){ vec[i + n - 1] = v[i]; } for(int i = n - 2; i >= 0; i--){ vec[i] = f(vec[2*i+1], vec[2*i+2]); } } void update(int k, E val){ k = k + n - 1; g(vec[k], val); while(k > 0){ k = (k - 1) / 2; vec[k] = f(vec[2*k+1], vec[2*k+2]); } } // [l, r) -> [a, b) (at k) int query(int a, int b, int k, int l, int r){ if(r <= a || b <= l)return -1; if(a <= l && r <= b)return *(vec[k].st.rbegin()); int ld = query(a, b, 2*k+1, l, (l+r)/2); int rd = query(a, b, 2*k+2, (l+r)/2, r); return max(ld, rd); } int query(int a, int b){ return query(a, b, 0, 0, n); } }; template using SegmentTree = struct SegmentTree_; using SegmentTreeI = SegmentTree; struct store{ ll p, t, r; int i; store(ll p, ll t, ll r, int i): p(p), t(t), r(r), i(i){} store(): store(0, 0, 0, 0){} bool operator<(const store &right) const{ if(p != right.p)return p > right.p; if(t != right.t)return t > right.t; return r > right.r; } }; struct Set{ set st; Set(): st(set{-1}){}; void insert(int x){ st.insert(x); } Set operator+(const Set &right) const{ Set s = *this; for(auto itr = right.st.begin(); itr != right.st.end(); ++itr){ s.insert(*itr); } return s; } }; int main(int argc, char const* argv[]) { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector vec(n); rep(i, n){ ll p, t, r; cin >> p >> t >> r; vec[i] = store(p, t, r, i); } sort(all(vec)); int N = 10000; SegmentTree seg = SegmentTree(N, [](Set& a, Set& b){return a + b;}, [](Set& a,int b){a.insert(b);}, Set(), vector()); vector ans; for(int i = 0; i < n; i++){ int tmp = seg.query(vec[i].t, N); if(tmp < vec[i].r)ans.pb(vec[i].i); seg.update(vec[i].t, vec[i].r); } sort(all(ans)); for(int i = 0; i < sz(ans); i++)cout << ans[i] + 1 << endl; return 0; }