The Geometer's Sketchpad is a popular commercial interactive geometry software program for exploring Euclidean geometry, algebra, calculus, and other areas of mathematics.
The Geometer's Sketchpad can solve most problems of plane geometry and plane analytic geometry, but it's powerless to solve solid geometry problems. Therefore, the famous mathematician BG, decided to develop a new software, named The Geometer's Sketchpad 3D.
Because of the huge amount of work to do, BG decided to start from basic three-dimensional transformations. Similar to two-dimensional transformations, three-dimensional transformations include three basic types:
1. Translation.
2. Scaling.
3. Rotation.
Now there are n points P1,P2,P3,…,Pn in the three-dimensional space, and BG wanted to implement the following several transformation operations:
1. For given integers l,r,x,y,z, translate points Pl,Pl+1,Pl+2,…,Pr by the vector (x,y,z) at the same time;
2. For given integers l,r,x,y,z and the real number k, scale points Pl,Pl+1,Pl+2,…,Pr by the scale factor k and the center point (x,y,z) at the same time;
3. For given integers l,r,x,y,z,x′,y′,z′ and the real number θ, rotate points Pl,Pl+1,Pl+2,…,Pr counterclockwise around the axis determined by the point (x,y,z) and the direction vector (x′,y′,z′) through an angle θ (in radian) at the same time.
In addition, there are some measurement operations:
1. For given integer i, calculate the current coordinates of the point Pi;
2. For given integers l,r, calculate the current length of the polygonal chain PlPl+1Pl+2⋯Pr. In other words, just calculate |PlPl+1|+|Pl+1Pl+2|+⋯+|Pr−1Pr|, where |PQ| means the Euclidean distance between points P and Q.
There are multiple test cases.
For each test case:
The first line contains two positive integers n,m (1≤n,m≤222222), representing the number of points and the number of operations.
Next n lines, each line contains three integers x,y,z, representing a point (x,y,z) in the three-dimensional space.
Next m lines, each line describes an operation (without quotes):
1. "Translation l r x y z", translate points;
2. "Scaling l r x y z k", scale points;
3. "Rotation l r x y z x′ y′ z′ θ", rotate points;
4. "Coordinates i", calculate the current coordinates of the point;
5. "Length l r", calculate the current length of the polygonal chain.
There is one blank line between successive tests. Values of n=m=0 indicate end of input.
For the all of the above variables, 1≤l,r,i≤n, −1000≤x,y,z,x′,y′,z′≤1000, 0<k≤2, −10≤θ≤10. k and θ are real numbers, given with at most 6digits after the decimal point, and all other numbers are integers. You can sure that the absolute value of the answer does not exceed 1010 at any time.
It is guaranteed ∑n+∑m≤106.
For each test case:
First output one line containing "Case #i:"(without quotes), where i is the test case number (starting from 1).
Then, for each "Coordinates" operator, output one line containing three space-separated real numbers, representing the current coordinates of the point; for each "Length" operator, output one line containing a real number, representing the current length of the polygonal chain.
Your output will be considered correct if the absolute or relative error of every number does not exceed 10−4.
5 10 0 0 0 2 0 0 2 1 0 0 1 0 0 0 0 Translation 1 5 1 1 0 Scaling 2 4 1 1 0 2 Coordinates 2 Coordinates 3 Length 2 3 Rotation 1 5 0 0 0 0 0 1 1.570796 Translation 1 2 0 0 100 Coordinates 2 Coordinates 3 Length 2 3 0 0
Case #1: 5.0000 1.0000 0.0000 5.0000 3.0000 0.0000 2.0000 -1.0000 5.0000 100.0000 -3.0000 5.0000 0.0000 100.0200