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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			while (n-- != 0)
			{
				var xy = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();
				double x1 = xy[0], y1 = xy[1], x2 = xy[2], y2 = xy[3], x3 = xy[4], y3 = xy[5];
				double a = 0, b = 0, c = 0, d = 0, p = 0, q = 0;
				if (y2 - y1 != 0)
				{
					a = (x1 - x2) / (y2 - y1);
					b = -1;
					p = -(x2 * x2 - x1 * x1 - y1 * y1 + y2 * y2) / (2 * (y2 - y1));
				}
				else
				{
					a = 1;
					p = (x1 + x2) / 2;
				}
				if (y3 - y2 != 0)
				{
					c = (x2 - x3) / (y3 - y2);
					d = -1;
					q = -(x3 * x3 - x2 * x2 - y2 * y2 + y3 * y3) / (2 * (y3 - y2));
				}
				else
				{
					b = 1;
					q = (x2 + x3) / 2;
				}
				double delta = a * d - b * c;
				double xp = (d * p - b * q) / delta;
				double yp = (a * q - c * p) / delta;
				double r = Math.Sqrt((x1 - xp) * (x1 - xp) + (y1 - yp) * (y1 - yp));

				Console.WriteLine("{0:F3} {1:F3} {2:F3}", xp, yp, r);
			}
		}
	}
}