{"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\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eThe Third Doctor Who once correctly said that travel between parallel universes is \"like travelling sideways\". However, he incorrectly thought that there were infinite parallel universes, whereas in fact, as we now all know, there will never be more than 250.\u003c/p\u003e\u003cp\u003eHeidi recently got her hands on a multiverse observation tool. She was able to see all $$$n$$$ universes lined up in a row, with non-existent links between them. She also noticed that the Doctor was in the $$$k$$$-th universe.\u003c/p\u003e\u003cp\u003eThe tool also points out that due to restrictions originating from the space-time discontinuum, the number of universes will never exceed $$$m$$$.\u003c/p\u003e\u003cp\u003eObviously, the multiverse is unstable because of free will. Each time a decision is made, one of two events will randomly happen: a new parallel universe is created, or a non-existent link is broken.\u003c/p\u003e\u003cp\u003eMore specifically, \u003c/p\u003e\u003cul\u003e \u003cli\u003e When a universe is created, it will manifest itself between any two adjacent universes or at one of the ends. \u003c/li\u003e\u003cli\u003e When a link is broken, it could be cut between any two adjacent universes. After separating the multiverse into two segments, the segment \u003cspan class\u003d\"tex-font-style-it\"\u003eNOT\u003c/span\u003e containing the Doctor will cease to exist. \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eHeidi wants to perform a simulation of $$$t$$$ decisions. Each time a decision is made, Heidi wants to know the length of the multiverse (i.e. the number of universes), and the position of the Doctor.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains four integers $$$n$$$, $$$k$$$, $$$m$$$ and $$$t$$$ ($$$2 \\le k \\le n \\le m \\le 250$$$, $$$1 \\le t \\le 1000$$$).\u003c/p\u003e\u003cp\u003eEach of the following $$$t$$$ lines is in one of the following formats: \u003c/p\u003e\u003cul\u003e \u003cli\u003e \"$$$1$$$ $$$i$$$\" — meaning that a universe is inserted at the position $$$i$$$ ($$$1 \\le i \\le l + 1$$$), where $$$l$$$ denotes the current length of the multiverse. \u003c/li\u003e\u003cli\u003e \"$$$0$$$ $$$i$$$\" — meaning that the $$$i$$$-th link is broken ($$$1 \\le i \\le l - 1$$$), where $$$l$$$ denotes the current length of the multiverse. \u003c/li\u003e\u003c/ul\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eOutput $$$t$$$ lines. Each line should contain $$$l$$$, the current length of the multiverse and $$$k$$$, the current position of the Doctor.\u003c/p\u003e\u003cp\u003eIt is guaranteed that the sequence of the steps will be valid, i.e. the multiverse will have length at most $$$m$$$ and when the link breaking is performed, there will be at least one universe in the multiverse.\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\u003e5 2 10 4\n0 1\n1 1\n0 4\n1 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4 1\n5 2\n4 2\n5 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eThe multiverse initially consisted of 5 universes, with the Doctor being in the second.\u003c/p\u003e\u003cp\u003eFirst, link 1 was broken, leaving the multiverse with 4 universes, and the Doctor in the first.\u003c/p\u003e\u003cp\u003eThen, a universe was added to the leftmost end of the multiverse, increasing the multiverse length to 5, and the Doctor was then in the second universe.\u003c/p\u003e\u003cp\u003eThen, the rightmost link was broken.\u003c/p\u003e\u003cp\u003eFinally, a universe was added between the first and the second universe.\u003c/p\u003e"}}]}