Lotus and Thermodynamics

Time Limit: 6000/3000 MS (Java/Others)

Memory Limit: 262144/262144 K (Java/Others)

Description

These days Lotus is interested in Brownian movement, so she wants to write a simulation program to meet her research desire.

The purpose of this procedure is to simulate the irregular movement of some points on a two-dimensional plane, and to support the following operations:

I x y: indicates that a new point $(x, y)$ is found in the plane. The index of the new point is the number of points already existing in the plane plus 1.

M l r x y: indicates that the points whose index belong to $[l, r]$ moved $x$ units right and $y$ units up.

R l r x y a: indicates that the points whose index belong to $[l, r]$ were rotated counterclockwise by the angle $a$. the rotation center is $(x, y)$. $a$ is radian, and $a$ contains at most one decimal place.

F l r x y d: indicates that the points whose index belong to $[l, r]$ scaled d times, the scaling center is $(x, y)$.It's Guaranteed that $d\in[0,1]$, and $d$ contains at most one decimal place.

Q id: Ask for the coordinates of the point whose index is $id$, output a line of two real numbers, separated by a space, Suppose the answers are x,y,you should use printf("%.0lf %.0lf\n",floor(x),floor(y)); to output them.

Input

The input includes multiple test cases. The first line contains a single integer $T$, the number of test cases.

The first line of each test case contains a single integer $q\in[1,100000]$, the number of operations.

The next $q$ line, each line contains the description of an operation.
For all number in the input file, it's guaranteed that they are in $[-1000,1000]$

It's guaranteed there are at most 2 test cases with $q > 10000$。

Output

For each operation Q, print a line of two real number presenting the answer.
It's guaranteed that the absolute value of the answer won't be greater than $10^7$.

Sample Input

2 6 I 4 -1 I 8 3 R 1 1 -4 8 -0.4 Q 1 F 1 2 -1 1 0.1 I -1 9 5 I 0 4 R 1 1 -6 9 1.9 Q 1 R 1 1 1 8 2.4 Q 1

Sample Output

-1 -4 -4 16 -2 -1

Hint

jiangzijing2015

Source

BestCoder Round #91

提交代码