#include using namespace std; // one-based numbering template struct Fenwick { vector bit; int N; T init; Fenwick(int n, T ini) { N = n; init = ini; bit.resize(n+1, init); } void add(int a, T w) { for (int x = a; x <= N; x += x & -x) { if (w > bit[x]) bit[x] = w; } } T max(int a) { T ret = init; for (int x = a; x > 0; x -= x & -x) { if (bit[x] > ret) ret = bit[x]; } return ret; } }; int main() { int n; cin >> n; vector< tuple > v(n); for (int i = 0; i < n; ++i) { cin >> get<0>(v[i]) >> get<1>(v[i]) >> get<2>(v[i]); get<3>(v[i]) = i+1; } sort(v.begin(), v.end()); vector reject; Fenwick< pair > f(10010, make_pair(-1, -1)); for (int i = n-1; i >= 0; --i) { pair p = f.max(10005 - get<1>(v[i])); pair q = f.max(10005 - (get<1>(v[i])+1)); if (q.first >= get<2>(v[i]) && q.second >= get<0>(v[i])) { reject.push_back(get<3>(v[i])); } else if (p.first >= get<2>(v[i]) && p.second > get<0>(v[i])) { reject.push_back(get<3>(v[i])); } else if (q.first > get<2>(v[i]) && q.second >= get<0>(v[i])) { reject.push_back(get<3>(v[i])); } f.add(10005 - get<1>(v[i]), make_pair(get<2>(v[i]), get<0>(v[i]))); } sort(reject.begin(), reject.end()); int k = 1; for (int i = 0; i < (int) reject.size(); ++i) { for (k; k < reject[i]; ++k) { cout << k << endl; } ++k; } for (k; k <= n; ++k) { cout << k << endl; } return 0; }