import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string; auto rdsp(){return readln.splitter;} void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;} void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);} void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}} void main() { int n; readV(n); int[] p, t, r; readC(n, p, t, r); struct S { int p, t, r, i; } auto s = new S[](n); foreach (i; 0..n) s[i] = S(p[i]+1, t[i]+1, r[i]+1, i); s.multiSort!("a.p>b.p", "a.t>b.t", "a.r>b.r"); auto st = new SegmentTree!(int, max)(10^^4+2), b = new bool[](n); b[] = true; foreach (si; s) { if (st[si.t..$] >= si.r) b[si.i] = false; st[si.t] = max(st[si.t], si.r); } foreach (i; 0..n) if (b[i]) writeln(i+1); } class SegmentTree(T, alias pred = "a + b") { import core.bitop, std.functional; alias predFun = binaryFun!pred; const size_t n, an; T[] buf; T unit; this(size_t n, T unit = T.init) { this.n = n; this.unit = unit; an = n == 1 ? 1 : (1 << ((n-1).bsr + 1)); buf = new T[](an*2); if (T.init != unit) buf[] = unit; } this(T[] init, T unit = T.init) { this(init.length, unit); buf[an..an+n][] = init[]; foreach_reverse (i; 1..an) buf[i] = predFun(buf[i*2], buf[i*2+1]); } void opIndexAssign(T val, size_t i) { buf[i += an] = val; while (i /= 2) buf[i] = predFun(buf[i*2], buf[i*2+1]); } pure T opSlice(size_t l, size_t r) { l += an; r += an; T r1 = unit, r2 = unit; while (l != r) { if (l % 2) r1 = predFun(r1, buf[l++]); if (r % 2) r2 = predFun(buf[--r], r2); l /= 2; r /= 2; } return predFun(r1, r2); } pure T opIndex(size_t i) { return buf[i+an]; } pure size_t opDollar() { return n; } }