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 JAVA (judge verdict: Wrong Answer)

import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		double[] d = new double[6];
		double ans_x;
		double ans_y;
		double tmp_a1;
		double tmp_b1;
		double tmp_c1;
		double tmp_a2;
		double tmp_b2;
		double tmp_c2;
		double tmp_r;
		double ans_r;
		
		Scanner scanner = new Scanner(System.in);
		int dset = scanner.nextInt();
		for( int i=0; i<dset; i++){
			for(int j=0; j<6; j++){
				d[j] = scanner.nextDouble();
			}
			tmp_a1 = 2 * (d[2] - d[0]);
			tmp_b1 = 2 * (d[3] - d[1]);
			tmp_c1 = Math.pow(d[0], 2) - Math.pow(d[2], 2) + Math.pow(d[1], 2) - Math.pow(d[3], 2);
			tmp_a2 = 2 * (d[4] - d[0]);
			tmp_b2 = 2 * (d[5] - d[1]);
			tmp_c2 = Math.pow(d[0], 2) - Math.pow(d[4], 2) + Math.pow(d[1], 2) - Math.pow(d[5], 2);
			
			ans_x = ( tmp_b1 * tmp_c2 - tmp_b2 * tmp_c1 ) / ( tmp_a1 * tmp_b2 - tmp_a2 * tmp_b1 );
			ans_y = ( tmp_c1 * tmp_a1 - tmp_c2 * tmp_a1 ) / ( tmp_a1 * tmp_b2 - tmp_a2 * tmp_b1 );
			ans_r = Math.sqrt( Math.pow((ans_x - d[0]), 2) + Math.pow((ans_y - d[1]), 2));
			ans_r = new BigDecimal(ans_r).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
			ans_x = new BigDecimal(ans_x).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
			ans_y = new BigDecimal(ans_y).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
			
			
			System.out.printf("%.3f %.3f %.3f\n", ans_x, ans_y, ans_r);
			
		}
	}
}