{"trustable":true,"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":"\u003cdiv class\u003d\"panel_content\"\u003eThe parking lot in the center of the capital has N parking spaces. You are asked to develop a program to write the parking log of the lot. The program is required to record such two operations which may happen in the lot:\u003cbr\u003e\u003cbr\u003eA: A motorcade with Mi cars applies for Mi parking spaces in a row, namely, continuous spaces [Si,Si+Mi-1]. A special constraint is that the number of free spaces between the coming motorcade and the last car parking before Si, should not be larger than Li. Note that, this constraint has no effect if there is no car before Si. What\u0027s more, the number of free spaces between the coming motorcade and the first car parking after Si+Mi-1 should not be larger than Ri. Also, you should ignore this constraint when Si+Mi-1 is last occupied space. The space with the smallest Si is selected when there are several candidate start places. The motorcade will leave if there are no spaces satisfying the conditions. After one motorcade is parked, its parking limits Li and Ri can be ignored when finding parking places for later coming motorcades. Your task is to find the Si, and return it as result.\u003cbr\u003e\u003cbr\u003eB. The k-th motorcade counted from left to right leaves the lot. Ignore this operation if there are no more than k motorcades in the parking lot.\u003cbr\u003e\u003cbr\u003eIn the very beginning, the spaces in the lot are all free.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"First line of the input is a single integer T(T \u0026lt;\u003d 10), indicates there are T test cases.\u003cbr\u003eFor each test case, the first line is two integers N(1 \u0026lt;\u003d N \u0026lt;\u003d 50000) Q(1 \u0026lt;\u003d Q \u0026lt;\u003d 100000), representing the size of the lot and the number of operations. \u003cbr\u003eThe following Q lines give the operations, in which lines with one char and three integers as \"A M L R\" (0 \u0026lt; M,L,R \u0026lt;\u003d 50000) representing operations of type A, and lines with one char and a single number are of type B."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, you should output \"Case #k:\" first. After that, your program should output the result place for each operation A, -1 if no place available.\u003cbr\u003e"}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n90 5\r\nA 77 2 2\r\nB 3\r\nB 1\r\nA 53 2 3\r\nA 7 3 3\r\n7 15\r\nA 3 1 1\r\nA 1 1 1\r\nB 1\r\nA 1 1 1\r\nA 1 1 1\r\nB 2\r\nA 2 1 1\r\nA 1 1 1\r\nA 2 1 1\r\nA 1 1 1\r\nB 4\r\nB 3\r\nB 2\r\nA 1 1 1\r\nA 2 1 1\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\r\n1\r\n1\r\n54\r\nCase #2:\r\n1\r\n4\r\n2\r\n1\r\n2\r\n5\r\n6\r\n-1\r\n-1\r\n3\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}