{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eThere are \u003cvar\u003e\\(N\\)\u003c/var\u003e pieces on a two-dimensional plane. The coordinates of Piece \u003cvar\u003e\\(i\\)\u003c/var\u003e are \u003cvar\u003e\\((X_i,Y_i)\\)\u003c/var\u003e. There may be multiple pieces at the same coordinates.\u003c/p\u003e\r\n\u003cp\u003eWe will do \u003cvar\u003e\\(M\\)\u003c/var\u003e operations \u003cvar\u003e\\(\\mathrm{op}_1, \\ldots, \\mathrm{op}_M\\)\u003c/var\u003e, one by one. There are four kinds of operations, described below along with their formats in input.\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003ccode\u003e1\u003c/code\u003e:Rotate every piece \u003cvar\u003e\\(90\\)\u003c/var\u003e degrees clockwise about the origin;\u003c/li\u003e\r\n\u003cli\u003e\u003ccode\u003e2\u003c/code\u003e:Rotate every piece \u003cvar\u003e\\(90\\)\u003c/var\u003e degrees counterclockwise about the origin;\u003c/li\u003e\r\n\u003cli\u003e\u003ccode\u003e3 p\u003c/code\u003e:Move each piece to the point symmetric to it about the line \u003cvar\u003e\\(x\u003dp\\)\u003c/var\u003e;\u003c/li\u003e\r\n\u003cli\u003e\u003ccode\u003e4 p\u003c/code\u003e:Move each piece to the point symmetric to it about the line \u003cvar\u003e\\(y\u003dp\\)\u003c/var\u003e.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cp\u003eYou are given \u003cvar\u003e\\(Q\\)\u003c/var\u003e queries. In the \u003cvar\u003e\\(i\\)\u003c/var\u003e-th query, given two integers \u003cvar\u003e\\(A_i\\)\u003c/var\u003e and \u003cvar\u003e\\(B_i\\)\u003c/var\u003e, print the coordinates of Piece \u003cvar\u003e\\(B_i\\)\u003c/var\u003e just after the \u003cvar\u003e\\(A_i\\)\u003c/var\u003e-th operation. Here, the moment just before the \u003cvar\u003e\\(1\\)\u003c/var\u003e-st operation is considered to be the moment just after \"the \u003cvar\u003e\\(0\\)\u003c/var\u003e-th operation\".\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Constraints","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eAll values in input are integers.\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq N \\leq 2\\times 10^5\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq M \\leq 2\\times 10^5\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq Q \\leq 2\\times 10^5\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(-10^9 \\leq X_i,Y_i \\leq 10^9\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(\\mathrm{op}_i\\)\u003c/var\u003e is in the format of one of the four kinds of operations.\u003c/li\u003e\r\n\u003cli\u003eIn an operation with the form \u003ccode\u003e3 p\u003c/code\u003e or \u003ccode\u003e4 p\u003c/code\u003e, \u003cvar\u003e\\(-10^9 \\leq p \\leq 10^9\\)\u003c/var\u003e.\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(0 \\leq A_i \\leq M\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 \\leq B_i \\leq N\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Input","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eInput is given from Standard Input in the following format:\u003c/p\u003e\r\n\u003cpre\u003e\u003cvar\u003e\\(N\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(X_1\\)\u003c/var\u003e \u003cvar\u003e\\(Y_1\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(\\vdots\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(X_N\\)\u003c/var\u003e \u003cvar\u003e\\(Y_N\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(M\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(\\mathrm{op}_1\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(\\vdots\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(\\mathrm{op}_M\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(Q\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(A_1\\)\u003c/var\u003e \u003cvar\u003e\\(B_1\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(\\vdots\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(A_Q\\)\u003c/var\u003e \u003cvar\u003e\\(B_Q\\)\u003c/var\u003e\r\n\u003c/pre\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Output","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003ePrint the response to each query in its own line: the \u003cvar\u003e\\(x\\)\u003c/var\u003e- and \u003cvar\u003e\\(y\\)\u003c/var\u003e-coordinates, in this order, with space in between.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 1","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\u003e1\r\n1 2\r\n4\r\n1\r\n3 3\r\n2\r\n4 2\r\n5\r\n0 1\r\n1 1\r\n2 1\r\n3 1\r\n4 1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1 2\r\n2 -1\r\n4 -1\r\n1 4\r\n1 0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\u003cp\u003eInitially, the only piece - Piece \u003cvar\u003e\\(1\\)\u003c/var\u003e - is at \u003cvar\u003e\\((1, 2)\\)\u003c/var\u003e. Each operation moves the piece as follows: \u003cvar\u003e\\((1,2)\\to(2,-1)\\to(4,-1)\\to(1,4)\\to(1,0)\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 2","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\n1000000000 0\r\n0 1000000000\r\n4\r\n3 -1000000000\r\n4 -1000000000\r\n3 1000000000\r\n4 1000000000\r\n2\r\n4 1\r\n4 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5000000000 4000000000\r\n4000000000 5000000000\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\u003c/section\u003e\r\n"}}]}