import std.conv, std.functional, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.container, std.math, std.numeric, std.range, std.regex, std.typecons; import core.bitop; class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; } int readInt() { return readToken.to!int; } long readLong() { return readToken.to!long; } real readReal() { return readToken.to!real; } bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } } bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } } int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; } int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); } int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); } enum LIM = 10^^4; int[] bit; void update(int pos, int val) { for (int x = pos; x < bit.length; x |= x + 1) { chmin(bit[x], val); } } int rangeMin(int pos) { int mn = LIM + 1; for (int x = pos - 1; x >= 0; x = (x & (x + 1)) - 1) { chmin(mn, bit[x]); } return mn; } int N; Tuple!(int, "a", int, "b", int, "c", int, "id")[] P; void main() { try { for (; ; ) { N = readInt(); P.length = N; foreach (i; 0 .. N) { P[i].a = readInt(); P[i].b = readInt(); P[i].c = readInt(); P[i].id = i; } foreach (i; 0 .. N) { P[i].a = LIM - P[i].a; P[i].b = LIM - P[i].b; P[i].c = LIM - P[i].c; } P.sort; auto ans = new bool[N]; bit = new int[LIM + 1]; bit[] = LIM + 1; for (int j = 0, k; j < N; j = k) { for (k = j; k < N && P[j].a == P[k].a; ++k) {} debug { writeln(P[j .. k]); } foreach (p; P[j .. k]) { if (rangeMin(p.b + 1) <= p.c) { debug { writeln("found(a) ", p); } ans[p.id] = true; } } foreach (p; P[j .. k]) { update(p.b, p.c); } foreach (p; P[j .. k]) { if (rangeMin(p.b) <= p.c) { debug { writeln("found(b) ", p); } ans[p.id] = true; } if (rangeMin(p.b + 1) < p.c) { debug { writeln("found(c) ", p); } ans[p.id] = true; } } } foreach (i; 0 .. N) { if (!ans[i]) { writeln(i + 1); } } } } catch (EOFException e) { } }