void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.typecons; int n, k; rd(n, k); alias Query=Tuple!(int, "t", long, "v"); auto que=new Query[](n); foreach(i; 0..n){ auto args=readln.split.to!(long[]); if(args.length==1) que[i].t=2; else que[i].t=1, que[i].v=args[$-1]; } int[long] compression(Query[] q){ long[] vs; foreach(e; q)if(e.t==1) vs~=e.v; sort(vs); int[long] ret; foreach(v; vs){ if(v in ret) continue; ret[v]=to!(int)(ret.length); } return ret; } long[int] make_inv(int[long] map){ long[int] ret; foreach(v; map.keys){ ret[map[v]]=v; } return ret; } auto map=compression(que), inv=make_inv(map); auto tree=new SquareRootDecomposition(map.length.to!(int)); foreach(q; que){ if(q.t==1){ tree.add(map[q.v], 1); }else{ auto v=tree.find(k); if(v>=0){ tree.add(v, -1); writeln(inv[v]); }else{ writeln(-1); } } } } class SquareRootDecomposition{ int D=1; int[] val, bucsum; this(int n){ while(D*D=x){ foreach(int j; 0..D){ if(s+val[i*D+j]>=x){ ret=i*D+j; break loop; }else{ s+=val[i*D+j]; } } }else{ s+=bucsum[i]; } } return ret; } } void rd(Query...)(ref Query x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, ref e; x){ e=l[i].to!(typeof(e)); } }