#abc189e. [abc189_e]Rotate and Flip

[abc189_e]Rotate and Flip

Problem Statement

There are NN pieces on a two-dimensional plane. The coordinates of Piece ii are (Xi,Yi)(X_i,Y_i). There may be multiple pieces at the same coordinates.

We will do MM operations mathrmop1,ldots,mathrmopM\\mathrm{op}_1, \\ldots, \\mathrm{op}_M, one by one. There are four kinds of operations, described below along with their formats in input.

  • 1:Rotate every piece 9090 degrees clockwise about the origin;
  • 2:Rotate every piece 9090 degrees counterclockwise about the origin;
  • 3 p:Move each piece to the point symmetric to it about the line x=px=p;
  • 4 p:Move each piece to the point symmetric to it about the line y=py=p.

You are given QQ queries. In the ii-th query, given two integers AiA_i and BiB_i, print the coordinates of Piece BiB_i just after the AiA_i-th operation. Here, the moment just before the 11-st operation is considered to be the moment just after "the 00-th operation".

Constraints

  • All values in input are integers.
  • 1leqNleq2times1051 \\leq N \\leq 2\\times 10^5
  • 1leqMleq2times1051 \\leq M \\leq 2\\times 10^5
  • 1leqQleq2times1051 \\leq Q \\leq 2\\times 10^5
  • \-109leqXi,Yileq109\-10^9 \\leq X_i,Y_i \\leq 10^9
  • mathrmopi\\mathrm{op}_i is in the format of one of the four kinds of operations.
  • In an operation with the form 3 p or 4 p, \-109leqpleq109\-10^9 \\leq p \\leq 10^9.
  • 0leqAileqM0 \\leq A_i \\leq M
  • 1leqBileqN1 \\leq B_i \\leq N

Input

Input is given from Standard Input in the following format:

NN X1X_1 Y1Y_1 vdots\\vdots XNX_N YNY_N MM mathrmop1\\mathrm{op}_1 vdots\\vdots mathrmopM\\mathrm{op}_M QQ A1A_1 B1B_1 vdots\\vdots AQA_Q BQB_Q

Output

Print the response to each query in its own line: the xx- and yy-coordinates, in this order, with space in between.


Sample Input 1

1
1 2
4
1
3 3
2
4 2
5
0 1
1 1
2 1
3 1
4 1

Sample Output 1

1 2
2 -1
4 -1
1 4
1 0

Initially, the only piece - Piece 11 - is at (1,2)(1, 2). Each operation moves the piece as follows: (1,2)to(2,1)to(4,1)to(1,4)to(1,0)(1,2)\\to(2,-1)\\to(4,-1)\\to(1,4)\\to(1,0).


Sample Input 2

2
1000000000 0
0 1000000000
4
3 -1000000000
4 -1000000000
3 1000000000
4 1000000000
2
4 1
4 2

Sample Output 2

5000000000 4000000000
4000000000 5000000000