{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eKing Kog got annoyed of the usual laxity of his knights\u0026nbsp;— they can break into his hall without prior notice! Thus, the King decided to build a reception with a queue where each knight chooses in advance the time when he will come and how long the visit will take. The knights are served in the order of the recorded time, but each knight has to wait until the visits of all the knights before him are finished.\u003c/p\u003e\u003cp\u003ePrincess Keabeanie wants to see her father. However, she does not want to interrupt the knights so she joins the queue. Unfortunately, the knights change their minds very often\u0026nbsp;— they can join the queue or cancel their visits. Please help the princess to understand how long she will have to wait until she sees her father if she enters the queue at the specified moments of time given the records at the reception.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line of the input contains a single integer $$$q$$$ ($$$1 \\leq q \\leq 3 \\cdot 10^5$$$)\u0026nbsp;— the number of events. An event can be of three types: \u003cspan class\u003d\"tex-font-style-underline\"\u003ejoin\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-underline\"\u003ecancel\u003c/span\u003e, or \u003cspan class\u003d\"tex-font-style-underline\"\u003equery\u003c/span\u003e.\u003c/p\u003e\u003cul\u003e \u003cli\u003e Join \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e+ $$$t$$$ $$$d$$$\u003c/span\u003e\" ($$$1 \\leq t, d \\leq 10^6$$$)\u0026nbsp;— a new knight joins the queue, where $$$t$$$ is the time when the knight will come and $$$d$$$ is the duration of the visit.\u003c/li\u003e\u003cli\u003e Cancel \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e- $$$i$$$\u003c/span\u003e\" ($$$1 \\leq i \\leq q$$$)\u0026nbsp;— the knight cancels the visit, where $$$i$$$ is the number (counted starting from one) of the corresponding join event in the list of all events.\u003c/li\u003e\u003cli\u003e Query \"\u003cspan class\u003d\"tex-font-style-tt\"\u003e? $$$t$$$\u003c/span\u003e\" ($$$1 \\leq t \\leq 10^6$$$)\u0026nbsp;— Keabeanie asks how long she will wait if she comes at the time $$$t$$$. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eIt is guaranteed that after each event there are no two knights with the same entrance time in the queue. Cancel events refer to the previous joins that were not cancelled yet.\u003c/p\u003e\u003cp\u003eKeabeanie can come at the same time as some knight, but Keabeanie is very polite and she will wait for the knight to pass.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eFor each query write a separate line with the amount of time Keabeanie will have to wait.\u003c/p\u003e"}},{"title":"Examples","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\u003e19\n? 3\n+ 2 2\n? 3\n? 4\n+ 5 2\n? 5\n? 6\n+ 1 2\n? 2\n? 3\n? 4\n? 5\n? 6\n? 7\n? 9\n- 8\n? 2\n? 3\n? 6\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e0\n1\n0\n2\n1\n3\n2\n1\n2\n1\n0\n0\n2\n1\n1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}