War Among the Stars

Compute the shortest distance between two tetrahedra in space, given the coordinates of their eight vertices.

Hard8GeometryImplementationBrute forceInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

A long time ago in a galaxy far, far away, an empire ruled over everyone. A rebel alliance that refused to accept this decided to fight back and bring democracy and peace to all peoples.

Captain Cael, one of the rebel commanders, is sailing through space in his cruiser when he spots an Imperial ship. By the aesthetic standards of that era every ship is a tetrahedron. After the empire opens with a surprise attack, Cael sees that he is in firing position and that he may mount the cannon at any point of his own ship.

The power of the weapon is fixed, so Cael wants to place the cannon so that the energy beam travels the shortest possible distance to the Imperial ship and his losses stay small. He asked you, sub captain Cin Talig, to compute the shortest distance between the rebel ship and the Imperial ship.

Input

The input contains several test cases. The first line contains an integer TT, the number of test cases. Each test case consists of eight lines, and each line describes the coordinates of one vertex of a ship. The first four lines give the vertices of the rebel ship, and the next four lines give the vertices of the Imperial ship.

Each coordinate line contains three integers XX, YY, ZZ (103X103-10^3 \le X \le 10^3, 103Y103-10^3 \le Y \le 10^3, 103Z103-10^3 \le Z \le 10^3), the position of that vertex in space. The four vertices of each ship always form a tetrahedron of nonzero volume, and the two ships never touch or overlap.

Output

For each test case print one line with the distance between the two ships, rounded to two decimal places. Always print both digits after the decimal point, so a distance of 4 is printed as 4.00. The distance between the two ships is always greater than zero, and no answer lies exactly on a rounding tie.