void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.container; int q, k; rd(q, k); // auto qmax=new BinaryHeap!(Array!(long))(), // qmin=new BinaryHeap!(Array!(long), "a>b")(); auto qmax=new RedBlackTree!(long, "a>b", true), qmin=new RedBlackTree!(long, "a=k){ writeln(qmax.front); qmax.removeFront; if(qmax.length0){ qmax.insert(qmin.front); qmin.removeFront; } }else{ writeln(-1); } } } } void rd(T...)(ref T 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)); } }