# Fix

Time Limit: 20000/10000 MS (Java/Others)

Memory Limit: 65536/65536 K (Java/Others)

[显示标签]

## Description

There are a few points on a plane, and some are fixed on the plane, some are not. We want to connect these points by some sticks so that all the points are fixed on the plane. Of course, we want to know the minimum length of the sum of the sticks.

As in the images, the black points are fixed on the plane and red ones are not, which need to be fixed by sticks.
All the points in the left image have been fixed. But the middle one is not, which we need add one stick to fix those four points (the right image shows that stick). Triangle is steady, isn’t it?

## Input

The input consists of multiply test cases. The first line of each test case contains one integer, n (1 <= n <= 18), which is the number of points. The next n lines, each line consists of three integers, x, y, c (0 <= x, y < 100). (x, y) indicate the coordinate of one point; c = 1 indicates this point is fixed; c = 0 indicates this point is not fixed. You can assume that no two points have the same coordinate.
The last test case is followed by a line containing one zero, which means the end of the input.

## Output

Output the minimum length with six factional digits for each test case in a single line. If you cannot fix all the points, then output “No Solution”.

## Sample Input

4
0 0 1
1 0 1
0 1 0
1 1 0
3
0 0 1
1 1 0
2 2 0
0

## Sample Output

4.414214
No Solution

lcy

## Source

“光庭杯”第五届华中北区程序设计邀请赛 暨 WHU第八届程序设计竞赛