Package for this problem was not updated by the problem writer or Codeforces administration after we’ve upgraded the judging servers. To adjust the time limit constraint, solution execution time will be multiplied by 2. For example, if your solution works for 400 ms on judging servers, then value 800 ms will be displayed and used to determine the verdict.

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

C. Inquisition

time limit per test

3 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputIn Medieval times existed the tradition of burning witches at steaks together with their pets, black cats. By the end of the 15-th century the population of black cats ceased to exist. The difficulty of the situation led to creating the EIC - the Emergency Inquisitory Commission.

The resolution #666 says that a white cat is considered black when and only when the perimeter of its black spots exceeds the acceptable norm. But what does the acceptable norm equal to? Every inquisitor will choose it himself depending on the situation. And your task is to find the perimeter of black spots on the cat's fur.

The very same resolution says that the cat's fur is a white square with the length of 10^{5}. During the measurement of spots it is customary to put the lower left corner of the fur into the origin of axes (0;0) and the upper right one — to the point with coordinates (10^{5};10^{5}). The cats' spots are nondegenerate triangles. The spots can intersect and overlap with each other, but it is guaranteed that each pair of the triangular spots' sides have no more than one common point.

We'll regard the perimeter in this problem as the total length of the boarders where a cat's fur changes color.

Input

The first input line contains a single integer *n* (0 ≤ *n* ≤ 100). It is the number of spots on the cat's fur. The *i*-th of the last *n* lines contains 6 integers: *x*_{1i}, *y*_{1i}, *x*_{2i}, *y*_{2i}, *x*_{3i}, *y*_{3i}. They are the coordinates of the *i*-th triangular spot (0 < *x*_{ji}, *y*_{ji} < 10^{5}).

Output

Print a single number, the answer to the problem, perimeter of the union of triangles. Your answer should differ from the correct one in no more than 10^{ - 6}.

Examples

Input

1

1 1 2 1 1 2

Output

3.4142135624

Input

3

3 3 10 3 3 10

1 1 9 4 5 6

2 2 11 7 6 11

Output

37.7044021497

Codeforces (c) Copyright 2010-2019 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Jul/19/2019 22:45:29 (f3).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|