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: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using Microsoft.Xna.Framework;

namespace AOJ.Volume0
{
    class Program0010
    {
        static void Main(string[] args)
        {
            int dataNum;
            Queue<string> inputs = new Queue<string>();
            Queue<Circle> results = new Queue<Circle>();

            dataNum = int.Parse(Console.ReadLine());

            for (int i = 0; i < dataNum; i++)
            {
                inputs.Enqueue(Console.ReadLine());
            }

            foreach (var input in inputs)
            {
                double[] param = input.Split(' ').Select(double.Parse).ToArray();

                Vector2[] points = new Vector2[3];
                for (int i = 0; i < 3; i++)
                {
                    points[i] = new Vector2(param[i * 2], param[i * 2 + 1]);
                }

                Nitobunsen n1, n2;

                n1 = new Nitobunsen((points[1] - points[0]) / 2,
                    new Vector2(-(points[1] - points[0]).Y, (points[1] - points[0]).X));


                n2 = new Nitobunsen((points[2] - points[0]) / 2,
                    new Vector2(-(points[2] - points[0]).Y, (points[2] - points[0]).X));

                var p = Nitobunsen.GetCrossingPoint(n1, n2);

                results.Enqueue(new Circle(p, (p - points[0]).Length()));
            }

            foreach (var result in results)
            {
                Console.WriteLine("{0:0.000} {1:0.000} {2:0.000}",
                    result.Point.X, result.Point.Y, result.R);

            }
        }
    }

    struct Nitobunsen
    {
        Vector2 BeginPoint, Direction;

        public Nitobunsen(Vector2 beginPoint, Vector2 direction)
        {
            this.BeginPoint = beginPoint;
            this.Direction = direction;
        }

        public static Vector2 GetCrossingPoint(Nitobunsen n1, Nitobunsen n2)
        {
            //n1.begin + m * n1.dir == n2.begin + l * n2.dir
            double m, l;

            var equation = new TwoEquation(n1.Direction.X, -n2.Direction.X,
                n2.BeginPoint.X - n1.BeginPoint.X,
                n1.Direction.Y, - n2.Direction.Y, n2.BeginPoint.Y - n1.BeginPoint.Y);

            equation.Solve(out m, out l);

            return n1.BeginPoint + m * n1.Direction;
        }
    }

    class TwoEquation
    {
        double a1, b1, c1, a2, b2, c2;

        public TwoEquation(double a1, double b1, double c1, double a2, double b2, double c2)
        {
            this.a1 = a1;
            this.b1 = b1;
            this.c1 = c1;
            this.a2 = a2;
            this.b2 = b2;
            this.c2 = c2;
        }

        public void Solve(out double x, out double y)
        {
            if (a1 == 0)
            {
                y = c1 / b1;
                x = (c2 - b2 * y) / a2;
            }
            else
            {
                double factor = a2 / a1;

                a2 -= a1 * factor;
                b2 -= b1 * factor;
                c2 -= c1 * factor;

                y = c2 / b2;
                x = (c1 - b1 * y) / a1;
            }
        }
    }

    struct Vector2
    {
        public double X, Y;

        public Vector2(double x, double y)
        {
            this.X = x;
            this.Y = y;
        }

        public static Vector2 Add(Vector2 v1, Vector2 v2)
        {
            return new Vector2(v1.X + v2.X, v1.Y + v2.Y);
        }


        public static Vector2 operator +(Vector2 v1, Vector2 v2)
        {
            return Add(v1, v2);
        }


        public static Vector2 Subtract(Vector2 v1, Vector2 v2)
        {
            return new Vector2(v1.X - v2.X, v1.Y - v2.Y);
        }

        public static Vector2 operator- (Vector2 v1, Vector2 v2)
        {
            return Subtract(v1, v2);
        }

        public static Vector2 Multiply(Vector2 v1, Vector2 v2)
        {
            return new Vector2(v1.X * v2.X, v1.Y * v2.Y);
        }


        public static Vector2 operator* (Vector2 v1, Vector2 v2)
        {
            return Multiply(v1, v2);
        }

        public static Vector2 Multiply(double x, Vector2 v)
        {
            return new Vector2(x * v.X, x * v.Y);
        }

        public static Vector2 operator *(double x, Vector2 v)
        {
            return Multiply(x, v);
        }

        public static Vector2 Divide(Vector2 v, double x)
        {
            return new Vector2(v.X / x, v.Y / x);
        }

        public static Vector2 operator /(Vector2 v, double x)
        {
            return Divide(v, x);
        }

        public double Length()
        {
            return Math.Sqrt(X * X + Y * Y);
        }
    }

    struct Circle
    {
        public Vector2 Point;
        public double R;

        public Circle(Vector2 point, double r)
        {
            this.Point = point;
            this.R = r;
        }
    }
}