#include #include #include #include using namespace std; struct R { map> mp; void insert(int x, int y, int z) { auto it = mp.upper_bound(x); for (;;) { if (it != mp.end() && y <= it->second.first) return; if (it == mp.begin()) break; it--; if (y < it->second.first || x == it->first && y == it->second.first) break; it = mp.erase(it); } mp[x] = make_pair(y, z); } }; int main() { int n; cin >> n; map mp; vector> vs(10001); vector x(n), y(n), z(n); for (int i = 0; i < n; i++) { cin >> x[i] >> y[i] >> z[i]; vs[z[i]].push_back(i); } R r; vector ans; for (int i = 10000; i >= 0; i--) { for (int j : vs[i]) { r.insert(x[j], y[j], z[j]); } for (int j : vs[i]) { if (r.mp.count(x[j]) && r.mp[x[j]] == make_pair(y[j], z[j])) { ans.push_back(j); } } } sort(ans.begin(), ans.end()); for (int i : ans) cout << i + 1 << endl; }