#### 265. Wizards

time limit per test: 0.5 sec.
memory limit per test: 65536 KB
input: standard
output: standard

The magical school of nature exists for thousands years. The wizards of the school are mastered in controlling animate nature. But it is still extremely difficult for them to manipulate matter itself. The best mages of the school were trying to learn the ways of manipulating the world around them for a long time. They started with the space distortion. Ancient books mentioned three basic space distortion spells: Translation, Scaling and Rotation. But all the experiments failed because it was extremely hard to predict the way the spell would affect the space. Nowadays the experiments arose again and you are to write the program which would help wizards in predicting of the results of some complex distortion spells. Complex spell consists of N consecutive basic distortion spells. And you are to predict its effect on M control vertices. For your convenience wizards measure the space in some 3-dimensional Cartesian system.
While casting Translation spell wizard specifies Translation vector and all the vertices are moved by the given x, y and z values.
While casting Scaling spell wizard specifies three Scaling parameters which show the Scaling factor for each of three coordinates (each x, y, and z coordinate of every vertex is multiplied by the corresponding Scaling factor).
While casting Rotation spell wizard specifies a point and Rotation angle and all the vertices are rotated in a clockwise direction about the ray from the origin through the specified point. The angle parameter specifies the angle of Rotation in degrees.

Input
The first line of the input file contains integer number N (1 <= N <= 1000). The next N lines describe complex spell. Each line contains one basic spell description in order they are applied. The first letter of each line specifies basic spell type. `T' stands for Translation spell, `S' stands for Scaling spell and `R' stands for Rotation spell. For Translation spell Translation vector is specified on the same line (three numbers: x, y, and z). For Scaling spell three Scaling factors are specified on the same line (three numbers: x, y, and z, each not greater than 1 by absolute value). For Rotation spell the point and the angle are specified on the same line (x, y, z and a, x^2+y^2+z^2>0). After that vertices description follows. First an integer number of vertices M is specified (1 <= M <= 100000). Then descriptions of M vertices follow. Each vertex description consists of 3 numbers - Cartesian coordinates of the vertex.
All the numbers in input are real and do not exceed 1000 by their absolute value.

Output
For each vertex in the input output its coordinates after the entire spell takes effect.

Sample test(s)

Input
Test #1
3
T 1.0 -2.4 0.7
S 0.2 4.0 2.0
R 0.0 0.0 1.0 2.0
3
0.0 0.0 1.0
0.0 1.0 0.0
1.0 0.0 0.0

Test #2
3
S 1.0 2.0 3.0
R 1.0 0.0 0.0 90.0
R 0.0 1.0 0.0 90.0
3
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0

Output
Test #1
0.53 -9.59 3.40
0.40 -5.59 1.40
0.73 -9.58 1.40

Test #2
0.00 0.00 -1.00
2.00 0.00 0.00
0.00 -3.00 0.00

 Author: Igor A. Kulkin Resource: Saratov SU Contest: Golden Fall 2004 Date: October 2, 2004

 Server time: 2016-09-26 07:37:17 Online Contester Team © 2002 - 2016. All rights reserved.