#P17099. [ICPC 2017 Qingdao R] Spacecraft
[ICPC 2017 Qingdao R] Spacecraft
Problem Description
The billion Quapler spacecraft, which launched in October 2016, in Dalian, is staring continuously at a patch of sky containing about 12 rare stars in the WF18 constellation. We are careful to set up the universe as a three dimensional space . The exact location of our planet is and the centre of WF18 constellation is . The ground detector recorded the initial state of Quapler. It faces the direction and the direction is on the left side.
The flight recorder captured its all orbit transformations with a total of in a timed sequence. Each record as a triple describes a rectilinear motion along the current direction of length and ending with a directional rotation.
The string is one of “R”,“L”,“D”,“U” indicating a rotation with radian to the right, the left, the down and the up side respectively. The recorded information is based on relative direction. That is say, the exact meaning of “R”, “L”, “D” and “U” should be discussed in the current direction of Quapler spacecraft itself.
To emphasize the importance of the studying, the scientists need to analyze the shortest distance between Quapler and the target constellation WF18.
Input Format
The first line consisting a number () indicating the number of test cases.
For each test case, the first line contains three float numbers , and where . The second line contains three float numbers and where . The third line is the total number of orbit transformation (). Each of the following lines consists a float number (), a string and a float number () described as above.
Output Format
For each test case, the shortest distance as a float number with the precision of 2 digits.
1
0 0 0
1 1 1
7
2 U 1.5708
2 U 1.5708
2 L 1.5708
2 L 1.5708
2 U 1.5708
2 U 1.5708
2 L 1.5708
1.41