from collections import deque import heapq import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) N = int(input()) PQR = tuple(tuple(map(int, input().split())) for _ in range(N)) P, Q, R = zip(*PQR) ptoi = {p: i for i, p in enumerate(sorted(set(P)))} M = len(ptoi) d = [[] for _ in range(M)] for i, p in enumerate(P): d[ptoi[p]].append(i) for i in range(M): stack = [] d[i].sort(key=lambda j: (Q[j], R[j])) for j in d[i]: if stack and R[stack[-1]] < R[j]: stack.pop() stack.append(j) d[i] = stack d[i].reverse() def merge(i, j): F = d[i] G = d[j] stf = [] stg = [] while F and G: if Q[F[-1]] <= Q[G[-1]]: heapq.heappush(stf, (R[F[-1]], F[-1])) F.pop() else: while stf and stf[0][0] <= R[G[-1]]: heapq.heappop(stf) stg.append(G.pop()) while F: heapq.heappush(stf, (R[F[-1]], F[-1])) F.pop() while G: while stf and stf[0][0] <= R[G[-1]]: heapq.heappop(stf) stg.append(G.pop()) stf = [k for _, k in stf] stf.sort(key=lambda k: Q[k], reverse=True) stg.reverse() while stf and stg: if Q[stf[-1]] <= Q[stg[-1]]: d[i].append(stf.pop()) else: d[i].append(stg.pop()) while stf: d[i].append(stf.pop()) while stg: d[i].append(stg.pop()) d[i].reverse() que = deque(range(M)) while len(que) > 1: a = que.popleft() b = que.popleft() if a > b: que.append(a) que.appendleft(b) continue merge(a, b) que.append(a) ans = [i + 1 for i in d[0]] ans.sort() print(*ans, sep="\n")