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;

public class Program
    {

        static List<string> ns = new List<string>();
        static List<double[]> rrr = new List<double[]>();

        static int j,k, N;
        static double[] B=new double[2];

        public static void Main() {
            Input0(rrr);
            double A = 0, R = 0;
            double[][] rr = new double[5][];
            foreach (double[] r in rrr) {
                /*
                r=(x1,y1,x2,y2,x3,y3)
                star={[p1](|p3|^2-|p2|^2)+cycled}/A
                */
                for (j = 0; j < 6; j += 2) {
                    A += r[j] * r[(j + 3) % 6] - r[j + 1] * r[(j + 2) % 6];
                }
                for (j = 0; j < 5; j++) {
                    rr[j] = new double[] { r[(j * 2) % 6], r[(j * 2 + 1) % 6] };
                }
                
                B[0] = B[1] = 0;
                for (k = 0; k < 2; k++) {
                    for (j = 0; j < 3; j++) {
                        B[k] += Xrs(rr[j], k) * 
                            (Abs(rr[j+2]) - Abs(rr[j+1]));
                    }
                    B[k] /= A;
                }

                R = Math.Sqrt(Abs(B[0]-r[0],B[1]-r[1]));

                PrintRound(B[0], B[1], R);
            }
        }

        public static double Xrs(double[] x,int i) {
            switch (i) {
                case 0: return x[1];
                case 1: return x[0];
                default:return 0;   
            }
        }

        public static double Abs(double[] x) {
            return x[0] * x[0] + x[1] * x[1];
        }

        public static double Abs(double x, double y) {
            return x * x + y * y;
        }

        public static void Input0(List<int[]> nnn) {
            Input0();
            foreach (string s1 in ns) {
                nnn.Add(SplitInt(s1));
            }
        }
        public static void Input0(List<double[]> rrr) {
            Input0();
            foreach (string s1 in ns) {
                rrr.Add(SplitDouble(s1));
            }
        }
        public static void Input0() {
            InputN(out N);
            Input(ns, N);
        }

        public static void Input(List<int> L, int N) {
            string s;
            for(int i=0;i< N;i++) {
                s = Console.ReadLine();
                if (string.IsNullOrEmpty(s)) break;
                L.Add(int.Parse(s));
            }
        }
        public static void Input(List<string> L, int N)
        {
            string s;
            for (int i = 0; i < N; i++) {
                s = Console.ReadLine();
                if (string.IsNullOrEmpty(s)) break;
                L.Add(s);
            }
        }

        public static void Input(List<int> L) {
            Input(L, int.MaxValue);
        }

        public static void Input(List<string> L) {
            Input(L, int.MaxValue);
        }

        public static int[] SplitInt(string s) {
            string[] ss = s.Split();
            int[] ns = new int[ss.Length];
            for (int i=0;i<ss.Length;i++) {
                ns[i] = int.Parse(ss[i]);
            }
            return ns;
        }
        public static double[] SplitDouble(string s) {
            string[] ss = s.Split();
            double[] rs = new double[ss.Length];
            for (int i = 0; i < ss.Length; i++) {
                rs[i] = double.Parse(ss[i]);
            }
            return rs;
        }

        public static void InputN(out int N) {
            string s = Console.ReadLine();
            N = int.Parse(s);
        }

        public static void PrintRound(params double[] G) {
            string S="";
            foreach (double d in G) {
                S =string.Concat(S,string.Format(" {0:F3}",d));
            }
            Console.WriteLine(S.Remove(1,1));
        }
    }