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 C# (judge verdict: Accepted)

using System;
class _0010
{
    public static void Main()
    {
        char[] splitChar = {' '};
        int n = int.Parse(Console.ReadLine());
        string str;
        double calcAB, calcAC, det;
        for (int i = 0; i < n; i++)
        {
            str = Console.ReadLine();
            string[] dataSet = str.Split(splitChar);
            vector2 a = new vector2(double.Parse(dataSet[0]), double.Parse(dataSet[1]));
            vector2 b = new vector2(double.Parse(dataSet[2]), double.Parse(dataSet[3]));
            vector2 c = new vector2(double.Parse(dataSet[4]), double.Parse(dataSet[5]));
            vector2 ab = new vector2((b - a).getX, (b - a).getY);
            vector2 ac = new vector2((c - a).getX, (c - a).getY);
            vector2 mab = new vector2(((b + a) / 2.0).getX, ((b + a) / 2.0).getY);
            vector2 mac = new vector2(((c + a) / 2.0).getX, ((c + a) / 2.0).getY);
            calcAB = ab.getX * mab.getX + ab.getY * mab.getY;
            calcAC = ac.getX * mac.getX + ac.getY * mac.getY;
            det = ab.getX * ac.getY - ab.getY * ac.getX;
            vector2 O = new vector2((ac.getY * calcAB - ab.getY * calcAC) / det, (ab.getX * calcAC - ac.getX * calcAB) / det);
            vector2 aO = new vector2((O - a).getX, (O - a).getY);
            Console.WriteLine(O.getX.ToString("f3") + " " + O.getY.ToString("f3") + " " + aO.size.ToString("f3"));
        }
    }
}
class vector2
{
    private double x, y;
    public vector2() { x = 0.0; y = 0.0; }
    public vector2(double i, double j) { x = i; y = j; }
    public static vector2 operator +(vector2 op1, vector2 op2)
    {
        vector2 result = new vector2();
        result.x = op1.x + op2.x;
        result.y = op1.y + op2.y;
        return result;
    }
    public static vector2 operator -(vector2 op1, vector2 op2)
    {
        vector2 result = new vector2();
        result.x = op1.x - op2.x;
        result.y = op1.y - op2.y;
        return result;
    }
    public static vector2 operator /(vector2 op1, double op2)
    {
        vector2 result = new vector2();
        result.x = op1.x / op2;
        result.y = op1.y / op2;
        return result;
    }
    public double size
    {
        get
        {
            return Math.Sqrt(Math.Pow(x, 2.0) + Math.Pow(y, 2.0));
        }
    }
    public double getX{
        get{
            return x;
        }
    }
    public double getY{
        get{
            return y;
        }
    }
}