#include struct P { int x, y, z; bool operator<(const P& p) const { return x != p.x ? x < p.x : y != p.y ? y < p.y : z < p.z; } }; struct P2 { int y, z; bool operator<(const P2& p) const { return y != p.y ? y < p.y : z < p.z; } }; int main() { int N; std::cin >> N; std::vector

s; std::map mp; for (int i = 0, x, y, z; i < N; i++) { std::cin >> x >> y >> z, s.push_back({x, y, z}), mp[s.back()] = i + 1; } std::sort(s.begin(), s.end()); std::map mp2; for (int i = N - 1; i >= 0; i--) { const P2 p = {s[i].y, s[i].z}; if (mp2.find(p) == mp2.end()) { mp2[p] = mp[s[i]]; } } std::set ps; for (const auto& q : s) { const P2 p = {q.y, q.z}; std::vector er; auto it = ps.upper_bound(p); if (it != ps.begin()) { it--; for (; it->z < q.z; it--) { er.push_back(*it); if (it == ps.begin()) { break; } } for (const auto& e : er) { ps.erase(e); } } ps.insert(p); } std::set ans; for (const auto& p : ps) { ans.insert(mp2[p]); } for (const int i : ans) { std::cout << i << std::endl; } return 0; }