Painting polygon outlines

For each polygon side, split it at intersections with later polygons, then sum over the pieces where the depth t counts how many later polygons contain the piece.

Hard8GeometryImplementationBrute forceNo attempts yetTime limit1sMemory limit512 MB

Problem

Adrian paints convex polygons on the coordinate plane with watercolors. He has no time to fill their interiors, but he still wants the drawing order to show, so the shade of each point on a polygon boundary depends on how many polygons cover that point. Say Adrian draws the polygons p1,p2,,pnp_1, p_2, \dots, p_n in this order. He paints a segment of polygon pjp_j with shade tt if that segment, except possibly its endpoints, lies inside exactly tt of the later polygons pj+1,,pnp_{j+1}, \dots, p_n.

Painting a segment with shade tt costs 1t+1\frac{1}{t+1} units of black paint per unit of length. Compute the total amount of paint Adrian needs in order to draw all the polygons.

Input

The first line contains the number of polygons nn (1n101 \le n \le 10). Then nn blocks follow, and the kk-th block describes polygon pkp_k. The first line of a block contains the number of vertices mm (3m203 \le m \le 20). Each of the next mm lines contains two integers xx and yy (0x,y1000 \le x, y \le 100), the coordinates of one vertex. The vertices are given counterclockwise, every polygon is convex, and no two consecutive sides are parallel.

Two different polygons never touch at a vertex or along a side. More precisely, if AA and BB are sides of different polygons pip_i and pjp_j, then AA and BB either have no common point at all, or they meet in exactly one point that lies in the interior of AA and in the interior of BB.

Output

Print the total amount of paint on one line, rounded to exactly six digits after the decimal point.

Notes

The picture for the first example.

first example

The picture for the second example.

second example