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;
using System.Linq;
using System.Text;

namespace CircumscribedCircleOfATriangle
{
    class Program
    {
        static void Main(string[] args)
        {
            var sb = new StringBuilder();
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                decimal[] input = Console.ReadLine().Split().Select(decimal.Parse).ToArray();
                decimal[] b = {input[2] - input[0], input[3] - input[1],
            (input[2] * input[2] - input[0] * input[0] - input[1] * input[1] + input[3] * input[3])/ 2,
            input[4] - input[0], input[5] - input[1],
            (input[4] * input[4] - input[0] * input[0] - input[1] * input[1] + input[5] * input[5])/ 2 };
                decimal d, e;
                if (b[0] == 0)
                {
                    d = b[2] / b[1];
                    e = (b[5] - d * b[4]) / b[3];
                }
                else
                {
                    d = (b[5] - b[2] * b[3] / b[0]) / (b[4] - b[3] * b[1] / b[0]);
                    e = (b[2] - d * b[1]) / b[0];
                }

                double distance = Math.Pow((double)((e - input[0]) * (e - input[0]) + (d - input[1]) * (d - input[1])), 0.5);
                distance = Math.Round(distance * 1000) / 1000;

                sb.AppendLine(String.Format("{0:0.000} {1:0.000} {2:0.000}", e, d, distance));
            }
            Console.Write(sb);
        }
    }
}