class SegmentTree(): def __init__(self, size, initial=-1): node_size = 1 while node_size < size: node_size <<= 1 self.st = [initial] * (2 * node_size - 1) self.size = node_size def update(self, target, new_value): target += self.size - 1 self.st[target] = new_value while target > 0: target = (target - 1) // 2 self.st[target] = max(self.st[target * 2 + 1], self.st[target * 2 + 2]) def query(self, a, b): # [a,b)の最大値を求める。 return self._query(a, b, 0, 0, self.size) def _query(self, a, b, k, l, r): if r <= a or b <= l: return -1 if a <= l and r <= b: return self.st[k] vl = self._query(a, b, k * 2 + 1, l, (l + r) // 2) vr = self._query(a, b, k * 2 + 2, (l + r) // 2, r) return max(vl, vr) def main(): n = int(input()) points = [tuple(map(int, input().split())) for i in range(n)] v_max = 10**4 partition_by_r = [[] for i in range(v_max + 1)] pt_max = SegmentTree(v_max + 1, -1) res = [] for i, point in enumerate(points): p, t, r = point partition_by_r[r].append((p, t, i + 1)) for ptis in partition_by_r[::-1]: ptis.sort(reverse=True) for pti in ptis: p, t, i = pti if t > pt_max.query(p, v_max + 1): res.append(i) pt_max.update(p, t) res.sort() for point_id in res: print(point_id) if __name__ == '__main__': main()