Weighted points#1174

Weighted points

20 seconds
64 megabytes
Easy

You are given points on the coordinate plane. The coordinates of each point P_i are (x_i, y_i), with an associated weight w_i.

For a point , define the distance function as follows:

Here, D(X, P_i) denotes the Euclidean distance between and P_i.

Find a point that minimizes . Output the minimum value of .

Input

The first line contains , the number of test cases. The first line of each test case contains , the number of points. Each of the next lines contains three integers x_i, y_i, and w_i separated by spaces.

It is guaranteed that T \leq 20, N \leq 1000, 0 \leq x_i, y_i, w_i \leq 1000.

Output

Output lines, each containing the minimum value of , rounded to three decimal places.

Examples

Example 1

Loading
Loading