Superpolygons#2251

Superpolygons

3 seconds
64 megabytes
Hard

On a plane, you are given superpolygons (1 \le N \le 30), which do not intersect themselves or each other. Each superpolygon is specified by the coordinates of its K_i vertices (3 \le K_i \le 30, 1 \le i \le N), listed in counterclockwise order. All coordinates are integers in the range to . You must connect these superpolygons with segments such that:

  1. Each segment connects exactly two superpolygons.

  2. The total length of all segments is minimized.

Additionally, between any two superpolygons, there must exist a path (a sequence of some segments and parts of the superpolygon boundaries).

Input

The first line contains the integer . Each of the next lines contains the integer K_i followed by K_i pairs of integers representing the coordinates of the vertices.

Output

Output a single line with the total length of the resulting segments, rounded to three decimal places.

Examples

Example 1

Loading
Loading