ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

NEERC 2008, Eastern subregion quarterfinals

About     Problems     Submit solution     Judge status     Standings
Contest is over

E. Death Conveyor

Time limit: 1.0 second
Memory limit: 64 MB
Problem illustration
The Empire experienced a severe economic crisis. Enormous funds had been spent on constructing Death Stars, but the Rebels had easily destroyed every single one of them. In this situation, there were two possible courses of action: either start peace negotiations with the Rebels and try to find a political solution to the conflict (and Darth Vader was definitely against that), or substantially cheapen the cost of constructing Death Stars. The second variant was chosen. The production was transferred to a neighboring galaxy, where labor was much cheaper. The industry there had long ago mastered the output of gigantic steel beams with a length of 1 standard sidereal unit. The assemblage of Death Stars from such beams was started. The Death Stars had the form of regular polyhedra (Platonic solids). At each vertex of such a polyhedron, a megagun was mounted; it could shoot along the ray originating from the center of the polyhedron and passing through that vertex. When the early-warning station detected an approaching Rebel ship, the whole Death Star turned so that the nearest megagun was aimed exactly at the ship. The amount of fuel consumed for the turning was proportional to the angle of rotation. The shot inevitably destroyed the Rebel's ship, and the Death Star remained in that position until the next attack.
In spite of the overwhelming technical advantage of the Empire, the Rebels continued attacking Death Stars, and the Empire continued spending huge sums on fuel and ammunition. The Imperial Minister of Finance was in despair. He planned to raise the issue of peace negotiations once again at the Emperor's audience. However, to protect himself from Darth Vader's anger, he wanted to present a clear economic justification. That is why he asked you to calculate the amount of fuel spent on repelling the Rebels' attacks.

Input

The first line specifies the Platonic solid in the form of which a Death Star is constructed. The names and main characteristics of these solids are given in the table below.
Polyhedron Vertices Edges Faces
tetrahedron 4 6 4
hexahedron 8 12 6
octahedron 6 12 8
dodecahedron 20 30 12
icosahedron 12 30 20
In the following line you are given the number n of the Rebels' attacks repelled by this Death Star (1 ≤ n ≤ 100). Each of the following n lines contains the vector of the attack, which is accurate to five fractional digits. The vectors are given in the coordinate system that is fixed with respect to the surrounding space. The geometric center of the Death Star stayed at the center of this coordinate system. You may assume that initially one of the megaguns was aimed exactly along the Oz axis in a positive direction and one of edges adjacent to it lied in the Oxz plane (in the half-plane x ≥ 0). The early warning station detected only those ships that moved from the depths of the Universe exactly in the direction of the center of the Death Star. Attacks followed each other in the given order, and there were sufficient time intervals between them. In the history of the Imperial Fleet, there were no cases when it was impossible to decide which megagun had to be aimed at the attacking ship.

Output

Output the cumulative angle of rotation in radians accurate to five fractional digits.

Sample

inputoutput
tetrahedron
5
0.00000 0.00000 -1.00000
-1.00000 0.00000 1.00000
0.00000 0.00000 -1.00000
-1.00000 0.00000 1.00000
0.00000 0.00000 -1.00000
1.78225
Problem Author: Pavel Atnashev
Problem Source: NEERC 2008, Eastern subregion quarterfinals
To submit the solution for this problem go to the Problem set: 1653. Death Conveyor