LHeaph; h.malloc(100,1); mapm; string a[100]; int g[4001]{}; ll@n,@q,b=0; rep(q){ ll@t; if(t<1||t>3)exit(8); if(t==1){ string@s; if(m.find(s)!=m.end())exit(9); ll@r; if(r<0||r>4000)exit(10); ll d=b++; if(g[r])exit(13); g[r]=d+1; if(b>100)exit(3); h.change(d,r); m[s]=d; a[d]=s; } if(t==2){ ll@x; n-=x; if(n<1)exit(4); } if(t==3){ string@s; ll@x; if(m.find(s)==m.end())exit(7); ll d=m[s]; if(a[d]!=s)exit(6); if(h.place[d]<0)exit(11); ll r=h.val[d]; if(!(r>=0&&r<=4000||r>=10000&&r<=14000))exit(12); if(g[r%10000]!=d+1)exit(14); if(r<4001){ // h.change(d,r+4001); h.change(d,r+10000); } n+=x; } while(h.size>n){ ll d=h.pop(); if(a[d]=="")exit(5); // wt(a[d]); puts(a[d].c_str()); m.erase(a[d]); a[d]=""; } }