#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct P {
    int x, y, z, i;
    P(int x_, int y_, int z_, int i_) : x(x_), y(y_), z(z_), i(i_) {}
};

bool operator<(P a, P b) {
    if (a.x != b.x) return a.x < b.x;
    if (a.y != b.y) return a.y < b.y;
    return a.z < b.z;
}

int main() {
    int n;
    cin >> n;
    vector<P> a;
    for (int i = 0; i < n; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        a.emplace_back(x, y, z, i);
    }
    sort(a.begin(), a.end());
    vector<int> mx(10002, -1);
    vector<bool> ans(n, true);
    for (int i = n - 1; i >= 0; i--) {
        if (a[i].z <= mx[a[i].y]) ans[a[i].i] = false;
        for (int j = 0; j <= a[i].y; j++) {
            mx[j] = max(mx[j], a[i].z);
        }
    }
    for (int i = 0; i < n; i++) {
        if (ans[i]) cout << i + 1 << endl;
    }
}