// Arup Guha
// 3/10/2016
// Solution to 2016 UCF High School Question: Nick and Moriarty

// Note: This solution is pretty ugly. I sort of meandered before honing in on how to solve the problem
//       and that's reflected in the poor design.

import java.util.*;

public class nick {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int numCases = stdin.nextInt();

		// Process each case.
		for (int loop=1; loop<=numCases; loop++) {

			// Read in input.
			int[] dim = new int[3];
			for (int i=0; i<3; i++) dim[i] = stdin.nextInt();
			int[] p1 = new int[3];
			for (int i=0; i<3; i++) p1[i] = stdin.nextInt();
			int[] p2 = new int[3];
			for (int i=0; i<3; i++) p2[i] = stdin.nextInt();

			// Output result.
			System.out.printf("Universe #%d: %.2f\n", loop, solve(dim, p1, p2));
		}
	}

	// Returns the distance between p1 and p2 (2D pts).
	public static double distance(int[] p1, int[] p2) {
		return Math.sqrt((p1[0]-p2[0])*(p1[0]-p2[0]) + (p1[1]-p2[1])*(p1[1]-p2[1]) );
	}

	public static double solve(int[] dim, int[] p, int[] p2) {

		double minDist = 1e9;

		// We need real copies of these things.
		int[] origCorner = new int[]{0,0};
		int[] origDim = Arrays.copyOf(dim, 3);
		int[] origP = Arrays.copyOf(p, 3);
		box orig = new box(origCorner, origDim, origP);
		int[] origP2 = Arrays.copyOf(p2, 3);
		box other = new box(origCorner, origDim, origP2);

		// Fix P1 to be on the bottom (z=0) and rotate p2 similarly.
		// Basically, we are reorienting the problem knowing that p1 is at the base.
		int curSideP1 = orig.getSide();
		if (curSideP1 == 2) {
			orig = orig.rPY();
			other = other.rPY();
		}
		else if (curSideP1 == 3) {
			orig = orig.rPX();
			other = other.rPX();
		}
		else if (curSideP1 == 4) {
			orig = orig.rNY();
			other = other.rNY();
		}
		else if (curSideP1 == 5) {
			orig = orig.rNX();
			other = other.rNX();
		}
		else if (curSideP1 == 6) {
			for (int i=0; i<2; i++) orig = orig.rPY();
			for (int i=0; i<2; i++) other = other.rPY();
		}

		// This is our fixed point we will measure all distances from.
		int[] origPt = orig.get2DPt();

		// Calculate the side of p2 (relative to p1 being on the bottom).
		int sideP2 = other.getSide();

		// This is the only easy case - both pts on the same side.
		if (sideP2 == 1) return distance(origPt, other.getXY());

		// Otherwise, we must rotate p2 down to the ground in several ways, and pick the best
		// answer.
		else {

			// Get all possible locations of p2 that might be minimum.
			ArrayList<int[]> possible = getPossible(other, sideP2);

			// Find the closest to p1 and return that distance.
			double res = distance(origPt, possible.get(0));
			for (int i=1; i<possible.size(); i++)
				res = Math.min(res, distance(origPt, possible.get(i)));
			return res;
		}
	}

	// Returns all possible locations of the point stored on other, starting on side.
	public static ArrayList<int[]> getPossible(box other, int side) {

		// Note: if we are sides 2, 3, 4 or 5, we only can come from one direction.
		//       if we're side 6, it's all 4 directions, this explains the crazy structure.

		// Store answers here and save the original box "other".
		ArrayList<int[]> res = new ArrayList<int[]>();
		box save = new box(other);

		// Try going "up" two rotations, and left 2 and right 2 from there.
		other = save.rPY();
		if (side == 6) {
			box[] list = new box[5];
			list[0] = other.rNX().rNX();
			for (int i=1; i<5; i++) list[i] = list[i-1].rPX();
			for (int i=0; i<5; i++) res.add(list[i].rPY().getXY());
		}

		// Not sure if I have to do all 5 sides here, but I was being safe.
		if (side == 2) {
			res.add(other.getXY());
			res.add(save.rPX().rPY().getXY());
			res.add(save.rPX().rPX().rPY().getXY());
			res.add(save.rNX().rPY().getXY());
			res.add(save.rNX().rNX().rPY().getXY());
		}

		// Now right.
		other = save.rPX();
		if (side == 6) {
			box[] list = new box[5];
			list[0] = other.rNY().rNY();
			for (int i=1; i<5; i++) list[i] = list[i-1].rPY();
			for (int i=0; i<5; i++) res.add(list[i].rPX().getXY());
		}

		// Same comment here about the 5 sides.
		if (side == 3) {
			res.add(other.getXY());
			res.add(save.rPY().rPX().getXY());
			res.add(save.rPY().rPY().rPX().getXY());
			res.add(save.rNY().rPX().getXY());
			res.add(save.rNY().rNY().rPX().getXY());
		}

		// Down
		other = save.rNY();
		if (side == 6) {
			box[] list = new box[5];
			list[0] = other.rNX().rNX();
			for (int i=1; i<5; i++) list[i] = list[i-1].rPX();
			for (int i=0; i<5; i++) res.add(list[i].rNY().getXY());
		}
		if (side == 4) {
			res.add(other.getXY());
			res.add(save.rPX().rNY().getXY());
			res.add(save.rPX().rPX().rNY().getXY());
			res.add(save.rNX().rNY().getXY());
			res.add(save.rNX().rNX().rNY().getXY());
		}

		// Left
		other = save.rNX();
		if (side == 6) {
			box[] list = new box[5];
			list[0] = other.rNY().rNY();
			for (int i=1; i<5; i++) list[i] = list[i-1].rPY();
			for (int i=0; i<5; i++) res.add(list[i].rNX().getXY());
		}
		if (side == 5) {
			res.add(other.getXY());
			res.add(save.rPY().rNX().getXY());
			res.add(save.rPY().rPY().rNX().getXY());
			res.add(save.rNY().rNX().getXY());
			res.add(save.rNY().rNY().rNX().getXY());
		}

		// Finally...
		return res;
	}
}

// This entire class has math I worked out by hand rotating a Rubix Cube on the table...
class box {

	// corner = bottom left (min x, min y) of this box.
	// dim = [xMax,yMax,zMax] dimensions of this box.
	// p = [x,y,z] of this point.
	public int[] corner;
	public int[] dim;
	public int[] p;

	public box(int[] myC, int[] myD, int[] myP) {
		corner = myC;
		dim = myD;
		p = myP;
	}

	public box(box other) {
		corner = Arrays.copyOf(other.corner, 2);
		dim = Arrays.copyOf(other.dim, 3);
		p = Arrays.copyOf(other.p, 3);
	}

	// Returns the side of point p on the box - 1 is on ground, 2 in +y, 3 is +x, 4 is -y, 5 is -x, 6 is top.
	public int getSide() {
		if (p[2] == dim[2]) return 6;
		else if (p[2] == 0) return 1;
		else if (p[1] == corner[1]+dim[1]) return 2;
		else if (p[0] == corner[0]+dim[0]) return 3;
		else if (p[1] == corner[1]) return 4;
		else if (p[0] == corner[0]) return 5;
		return 0;
	}

	public boolean zeroZ() {
		return p[2] == 0;
	}

	public int[] getXY() {
		return new int[]{p[0],p[1]};
	}

	// Rotate over the bottom edge of side 3 (positive X), wrapper function.
	public box rPX() {
		int[] newCorner = rPXnewCorner(dim, corner);
		int[] newDim = rXnewDim(dim);
		int[] newP = rotatePosX(dim, corner, p);
		return new box(newCorner, newDim, newP);
	}

	// Same as above, but negative X, over side 5 bottom edge.
	public box rNX() {
		int[] newCorner = rNXnewCorner(dim, corner);
		int[] newDim = rXnewDim(dim);
		int[] newP = rotateNegX(dim, corner, p);
		return new box(newCorner, newDim, newP);
	}

	// Rotates over side 2 bottom edge. (positive Y)
	public box rPY() {
		int[] newCorner = rPYnewCorner(dim, corner);
		int[] newDim = rYnewDim(dim);
		int[] newP = rotatePosY(dim, corner, p);
		return new box(newCorner, newDim, newP);
	}

	// Rotates over side 4 bottom edge. (negative Y)
	public box rNY() {
		int[] newCorner = rNYnewCorner(dim, corner);
		int[] newDim = rYnewDim(dim);
		int[] newP = rotateNegY(dim, corner, p);
		return new box(newCorner, newDim, newP);
	}

	public int[] get2DPt() {
		return new int[]{p[0], p[1]};
	}

	// x coordinate of new box is larger, y stays the same.
	private static int[] rPXnewCorner(int[] dim, int[] corner) {
		return new int[]{corner[0]+dim[0],corner[1]};
	}

	private static int[] rNXnewCorner(int[] dim, int[] corner) {
		return new int[]{corner[0]-dim[2],corner[1]};
	}

	// Here y coordinate is bigger, x stays the same.
	private static int[] rPYnewCorner(int[] dim, int[] corner) {
		return new int[]{corner[0],corner[1]+dim[1]};
	}

	private static int[] rNYnewCorner(int[] dim, int[] corner) {
		return new int[]{corner[0],corner[1]-dim[2]};
	}

	private static int[] rXnewDim(int[] dim) {
		return new int[]{dim[2],dim[1],dim[0]};
	}

	private static int[] rYnewDim(int[] dim) {
		return new int[]{dim[0],dim[2],dim[1]};
	}

	// Have to be careful here to do everything relative to p.
	private static int[] rotatePosX(int[] dim, int[] corner, int[] p) {
		int[] res = new int[3];
		res[0] = corner[0]+dim[0]+p[2];
		res[1] = p[1];
		res[2] = dim[0] - (p[0]-corner[0]);
		return res;
	}

	private static int[] rotateNegX(int[] dim, int[] corner, int[] p) {
		int[] res = new int[3];
		res[0] = corner[0]-p[2];
		res[1] = p[1];
		res[2] = p[0]-corner[0];
		return res;
	}

	private static int[] rotatePosY(int[] dim, int[] corner, int[] p) {
		int[] res = new int[3];
		res[0] = p[0];
		res[1] = corner[1]+dim[1]+p[2];
		res[2] = dim[1] - (p[1]-corner[1]);
		return res;
	}

	private static int[] rotateNegY(int[] dim, int[] corner, int[] p) {
		int[] res = new int[3];
		res[0] = p[0];
		res[1] = corner[1]-p[2];
		res[2] = p[1]-corner[1];
		return res;
	}
}