{"problem":{"name":"Rotate and Flip","description":{"content":"There are $N$ pieces on a two-dimensional plane. The coordinates of Piece $i$ are $(X_i,Y_i)$. There may be multiple pieces at the same coordinates. We will do $M$ operations $\\mathrm{op}_1, \\ldots, \\","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc189_e"},"statements":[{"statement_type":"Markdown","content":"There are $N$ pieces on a two-dimensional plane. The coordinates of Piece $i$ are $(X_i,Y_i)$. There may be multiple pieces at the same coordinates.\nWe will do $M$ operations $\\mathrm{op}_1, \\ldots, \\mathrm{op}_M$, one by one. There are four kinds of operations, described below along with their formats in input.\n\n*   `1`：Rotate every piece $90$ degrees clockwise about the origin;\n*   `2`：Rotate every piece $90$ degrees counterclockwise about the origin;\n*   `3 p`：Move each piece to the point symmetric to it about the line $x=p$;\n*   `4 p`：Move each piece to the point symmetric to it about the line $y=p$.\n\nYou are given $Q$ queries. In the $i$\\-th query, given two integers $A_i$ and $B_i$, print the coordinates of Piece $B_i$ just after the $A_i$\\-th operation. Here, the moment just before the $1$\\-st operation is considered to be the moment just after \"the $0$\\-th operation\".\n\n## Constraints\n\n*   All values in input are integers.\n*   $1 \\leq N \\leq 2\\times 10^5$\n*   $1 \\leq M \\leq 2\\times 10^5$\n*   $1 \\leq Q \\leq 2\\times 10^5$\n*   $-10^9 \\leq X_i,Y_i \\leq 10^9$\n*   $\\mathrm{op}_i$ is in the format of one of the four kinds of operations.\n*   In an operation with the form `3 p` or `4 p`, $-10^9 \\leq p \\leq 10^9$.\n*   $0 \\leq A_i \\leq M$\n*   $1 \\leq B_i \\leq N$\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$\n$X_1$ $Y_1$\n$\\vdots$\n$X_N$ $Y_N$\n$M$\n$\\mathrm{op}_1$\n$\\vdots$\n$\\mathrm{op}_M$\n$Q$\n$A_1$ $B_1$\n$\\vdots$\n$A_Q$ $B_Q$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc189_e","tags":[],"sample_group":[["1\n1 2\n4\n1\n3 3\n2\n4 2\n5\n0 1\n1 1\n2 1\n3 1\n4 1","1 2\n2 -1\n4 -1\n1 4\n1 0\n\nInitially, the only piece - Piece $1$ - is at $(1, 2)$. Each operation moves the piece as follows: $(1,2)\\to(2,-1)\\to(4,-1)\\to(1,4)\\to(1,0)$."],["2\n1000000000 0\n0 1000000000\n4\n3 -1000000000\n4 -1000000000\n3 1000000000\n4 1000000000\n2\n4 1\n4 2","5000000000 4000000000\n4000000000 5000000000"]],"created_at":"2026-03-03 11:01:14"}}