Minimum transmitter power

Place a flagship in 3D so the maximum weighted Manhattan distance to N ships is minimized, and report that minimum power rounded to six decimals.

Hard8GeometryBinary searchImplementationBrute forceNo attempts yetTime limit5sMemory limit512 MB

Problem

Near the planet Mars, in a faraway galaxy much like our own, the imperial forces and the rebels are fighting. The rebel fleet has NN ships. Ship ii sits at the point (xi,yi,zi)(x_i, y_i, z_i) and carries a receiver of power pip_i. The rebels need to send orders from the flagship to every ship, but their budget is tight and they cannot buy a strong transmitter.

If the flagship is placed at (x,y,z)(x, y, z), then reaching the ship at (xi,yi,zi)(x_i, y_i, z_i) whose receiver has power pip_i takes a transmitter power of at least

xix+yiy+zizpi\frac{|x_i - x| + |y_i - y| + |z_i - z|}{p_i}

Choose the flagship position that minimizes the transmitter power needed to reach every ship, and report that power. The flagship coordinates do not have to be integers.

Input

The first line contains the number of test cases TT.

The first line of each test case contains the number of ships NN. The next NN lines each contain four integers xix_i, yiy_i, ziz_i and pip_i separated by single spaces. The first three are the coordinates of ship ii and the last one is the power of its receiver. Two or more ships may share the same coordinates.

Limits

  • 1T101 \le T \le 10
  • 1N101 \le N \le 10
  • 0xi,yi,zi1060 \le x_i, y_i, z_i \le 10^6
  • 1pi1061 \le p_i \le 10^6

Output

For each test case print one line in the following format.

Case #X: Y

XX is the number of the test case and YY is the smallest transmitter power that reaches every ship of the fleet. Round YY to six digits after the decimal point and print all six digits even when they are zeros. When the discarded part is exactly one half, round up.

Hint

The flagship coordinates need not be integers. If the ships are at (0,0,0)(0, 0, 0), (1,2,0)(1, 2, 0), (3,4,0)(3, 4, 0) and (2,1,0)(2, 1, 0) and every receiver has power 11, a flagship at (1.5,2,0)(1.5, 2, 0) reaches all of them with transmitter power 3.53.5. With a single ship the flagship can sit on top of it, so the answer is 00.