{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n翎羽与炎熔正在排队提交简历。他们觉得排队的过程很无聊,假设一开始有N(从1开始编号)个干员在队列中,人事部主管梓兰正在对他们进行操作:\n \u003cbr\u003e1.\u0026nbsp;\u0026nbsp;Top x :把编号为x的\u003cdel\u003e三星\u003c/del\u003e干员放到队列的最前面\n \u003cbr\u003e2.\u0026nbsp;\u0026nbsp;Query x: 询问编号为x的干员所在的位置\n \u003cbr\u003e3.\u0026nbsp;\u0026nbsp;Rank x: 询问排在第x位的干员的编号\n\u003cbr\u003e其中x属于[1,N],由于阿米娅的催促,梓兰需要尽快回答问题,你可以帮助她吗?\n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"In the first line there is an integer T, indicates the number of test cases.(T\u0026lt;\u003d50) \n\u003cbr\u003eIn each case, the first line contains two integers N(1\u0026lt;\u003dN\u0026lt;\u003d10^8), Q(1\u0026lt;\u003dQ\u0026lt;\u003d10^5). Then there are Q lines, each line contain an operation as said above. \n\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output “Case d:“ at first line where d is the case number counted from one, then for each “Query x” operation ,output the current position of person x at a line, for each “Rank x” operation, output the current person at position x at a line."}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e1\n163 3\nRank 126\nTop 91\nRank 66\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003eCase 1:\n126\n65\n\u003c/pre\u003e"}}]}