"La umbra nucului bătrân
Pe banca învechită"
You are living in a 3D world, so, since we want to have problems with real-life applications, we will give you a 3D geometry problem.
To simplify things, we say that the world is a cuboid and everything in the world has and coordinates in the interval and coordinates in the interval (since below zero you are underground). We will also assume that the clouds can completely stop the light.
The sun emits parallel rays directed along the -axis. Its light goes straight down.
Now that we have established this, I'm going to tell you the problem.
Task
There are clouds in the sky. A cloud can be seen as a convex polygon with integer coordinates, with its vertices having the same coordinate. You want to compute the total area of the shadow visible on the ground and on other clouds.
Input data
The first line contains a single integer . On the following lines, the clouds are described in the following way:
- On the first line, there is representing the number of vertices describing the -th cloud.
- On the following lines, there are 3 integers , , and , the vertices of the cloud, given in counter-clockwise order.
Output data
Output a single value which represents the total area of the shadows. The answer will be considered correct if either the absolute or relative difference between your answer and the correct answer is less than .
Constraints and clarifications
- For each cloud, all vertices have the same coordinate.
- There are no two clouds with the same coordinate.
Example
stdin
2
4
0 0 5
2 0 5
2 2 5
0 2 5
4
1 1 8
3 1 8
3 3 8
1 3 8
stdout
8.00000
Explanation
The area of the shadow on the ground (made by both clouds) is , and the area of the shadow on the first cloud (made by the second cloud) is , for a total of .