Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Circumscribed Circle of A Triangle.

Write a program which prints the central coordinate $(p_x, p_y)$ and the radius $r$ of a circumscribed circle of a triangle which is constructed by three points $(x_1, y_1)$, $(x_2, y_2)$ and $(x_3, y_3)$ on the plane surface.

Input

Input consists of several datasets. In the first line, the number of datasets $n$ is given. Each dataset consists of:

$x_1$ $y_1$ $x_2$ $y_2$ $x_3$ $y_3$

in a line. All the input are real numbers.

Output

For each dataset, print $p_x$, $p_y$ and $r$ separated by a space in a line. Print the solution to three places of decimals. Round off the solution to three decimal places.

Constraints

$-100 \leq x_1, y_1, x_2, y_2, x_3, y_3 \leq 100$

$ n \leq 20$

Sample Input

1
0.0 0.0 2.0 0.0 2.0 2.0

Output for the Sample Input

1.000 1.000 1.414

Solution in JAVA (judge verdict: Wrong Answer)


import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] argv) throws IOException {
        //*
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int count = 1;
        count = Integer.parseInt(in.readLine());
        while (count-- > 0) {
            String s = in.readLine();
            if (s == null) {
                break;
            }
            f(s);
        }
        //*/
    }

    public static void f(String s) {
        String[] temp = s.split(" ");
        double[] points = new double[temp.length];
        for (int i = 0; i < temp.length; i++) {
            points[i] = Double.parseDouble(temp[i]);
        }
        double a = Math.sqrt(Math.pow(Math.abs(points[0] - points[2]), 2) + Math.pow(Math.abs(points[1] - points[3]), 2));
        double b = Math.sqrt(Math.pow(Math.abs(points[2] - points[4]), 2) + Math.pow(Math.abs(points[3] - points[5]), 2));
        double c = Math.sqrt(Math.pow(Math.abs(points[4] - points[0]), 2) + Math.pow(Math.abs(points[5] - points[1]), 2));
        double R = (a * b * c) / Math.sqrt((a + b + c) * (-a + b + c) * (a - b + c) * (a + b - c));
        double a1 = 2 * (points[2] - points[0]);
        double b1 = 2 * (points[3] - points[1]);
        double c1 = Math.pow(points[0], 2) - Math.pow(points[2], 2) + Math.pow(points[1], 2) - Math.pow(points[3], 2);
        double a2 = 2 * (points[2] - points[0]);
        double b2 = 2 * (points[5] - points[3]);
        double c2 = Math.pow(points[0], 2) - Math.pow(points[2], 2) + Math.pow(points[3], 2) - Math.pow(points[5], 2);
        double x = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
        double y = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
        System.out.println(String.format("%.3f %.3f %.3f", Math.round(x * 1000) / 1000.0, Math.round(y * 1000) / 1000.0, Math.round(R * 1000) / 1000.0));
    }
}