// Arup Guha
// Started last week, finished? 12/9/2015
// Got help from Timothy to figure out flip over line y = -5sqrt(3) for cases with 2nd pt on side 4,5,6 or 7

import java.util.*;

public class carl {

	final public static double C = 10/Math.sqrt(2);

	final public static double[] ROTANGLE = {0, Math.PI/3, 2*Math.PI/3, -Math.PI/3};

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int[] loc1 = new int[2];
		int[] loc2 = new int[2];
		loc1[0] = stdin.nextInt();
		int loop = 1;

		// Process each case.
		while (loc1[0] != -1) {
			loc1[1] = stdin.nextInt();
			loc2[0] = stdin.nextInt();
			loc2[1] = stdin.nextInt();

			// Flip two points on the bottom to the top.
			if (loc1[1] > 90 && loc2[1] > 90) {
				loc1[1] = 180 - loc1[1];
				loc2[1] = 180 - loc2[1];
			}

			// Makes first point with positive z.
			if (loc1[1] > 90) {
				int[] tmp = loc1;
				loc1 = loc2;
				loc2 = tmp;
			}

			// Put first point in triangle #1.
			if (loc1[0] > 90) {
				int sub = (loc1[0]-1)/90;
				loc1[0] -= (90*sub);
				loc2[0] = (loc2[0] - 90*sub + 360)%360;
			}

			// Get mapped points on xy plane, if we shift 1st plane to be on the ground
			// with vertices (-5,-5rt(3), 0), (5, -5rt(3), 0) and (0, 0, 0).
			double[] map1 = getMap(loc1);
			double[] map2 = getMap(getQ1(loc2));

			// Get the side of the other point.
			int side = getSide(loc2);

			// Now get the distance and output it.
			double res = solve(map1, map2, side);
			System.out.printf("Case %d: %.3f\n", loop, res);

			// Get next case.
			loc1[0] = stdin.nextInt();
			loop++;
		}
	}

	public static double[] getMap(int[] orig) {

		// Find solution to intersection between line and plane x+y+z = 10. t is parameter on line.
		int elevate = 90 - orig[1];
		double theta = orig[0]*Math.PI/180;
		double phi = elevate*Math.PI/180;
		double mag = Math.sqrt(1+Math.pow(Math.tan(phi), 2));
		double t = C/(Math.cos(theta) + Math.sin(theta) + Math.tan(phi));

		// Take point, rotate it -135 degrees, translate 5-5root(3) in y.
		double[] xy = new double[2];
		xy[0] = Math.cos(theta)*t;
		xy[1] = Math.sin(theta)*t;
		xy = rotate(xy, -Math.PI*3/4);
		xy = translate(xy, 0, 5-5*Math.sqrt(3));

		// Now, revolve point down to xy plane and return result.
		double[] res = new double[2];
		res[0] = xy[0];
		res[1] = Math.sqrt(3)*(xy[1] + 5*Math.sqrt(3)) - 5*Math.sqrt(3);
		return res;
	}

	// Standard 2D rotation matrix.
	public static double[] rotate(double[] orig, double angle) {
		double[] res = new double[2];
		res[0] = Math.cos(angle)*orig[0] - Math.sin(angle)*orig[1];
		res[1] = Math.sin(angle)*orig[0] + Math.cos(angle)*orig[1];
		return res;
	}

	// Returns orig translated by (shiftX, shiftY).
	public static double[] translate(double[] orig, double shiftX, double shiftY) {
		double[] res = new double[2];
		res[0] = orig[0] + shiftX;
		res[1] = orig[1] + shiftY;
		return res;
	}

	// Returns pt mapped to quadrant 1.
	public static int[] getQ1(int[] pt) {
		int[] res = new int[2];
		res[0] = pt[0];
		while (res[0] > 90) res[0] -= 90;
		if (pt[1] > 90) {
			res[1] = 180 - pt[1];
			res[0] = res[0];
		}
		else
			res[1] = pt[1];

		return res;
	}

	// Returns the side of pt. (top = 0,1,2,3. bottom = 4,5,6,7)
	public static int getSide(int[] pt) {
		if (pt[1] <= 90) return pt[0] > 0 ? (pt[0]-1)/90 : 0;
		return pt[0] > 0 ? 4 + (pt[0]-1)/90 : 4;
	}

	public static double solve(double[] pt1, double[] pt2, int side) {

		// Flip points that should be on the bottom.
		if (side >= 4) {
			pt2[1] = -5*Math.sqrt(3) - (pt2[1] + 5*Math.sqrt(3));
		}

		// Just one way to solve it.
		if (side < 4 && side != 2) pt2 = rotate(pt2, ROTANGLE[side]);

		// Try with two possible unfolded flips, left or right.
		else if (side == 2) {
			double[] try1 = rotate(pt2, ROTANGLE[side]);
			double[] try2 = rotate(pt2, -2*Math.PI/3);
			return Math.min(dist(pt1, try1), dist(pt1, try2));
		}

		// Try with this side's two possibilties, going down and left, or left and down.
		else if (side == 5) {

			// Down and left.
			double[] try1 = translate(pt2, 0, 10*Math.sqrt(3));
			try1 = rotate(try1, -Math.PI/3);
			try1 = translate(try1, 0, -10*Math.sqrt(3));

			// Left and down.
			double[] try2 = translate(pt2, 0, 10*Math.sqrt(3));
			try2 = rotate(try2, Math.PI/3);
			try2 = translate(try2, 15, -5*Math.sqrt(3));
			return Math.min(dist(pt1, try1), dist(pt1, try2));
		}

		// Try with this side's two possibilities, down and right, or right and down.
		else if (side == 7) {

			// Down and right.
			double[] try1 = translate(pt2, 0, 10*Math.sqrt(3));
			try1 = rotate(try1, Math.PI/3);
			try1 = translate(try1, 0, -10*Math.sqrt(3));

			// Right and down.
			double[] try2 = translate(pt2, 0, 10*Math.sqrt(3));
			try2 = rotate(try2, -Math.PI/3);
			try2 = translate(try2, -15, -5*Math.sqrt(3));
			return Math.min(dist(pt1, try1), dist(pt1, try2));
		}

		// This is the doozy - six possibilities.
		else if (side == 6) {

			// Bottom left
			double[] try1 = translate(pt2, 0, 10*Math.sqrt(3));
			try1 = rotate(try1, 2*Math.PI/3);
			try1 = translate(try1, 0, -10*Math.sqrt(3));

			// Bottom right
			double[] try2 = translate(pt2, 0, 10*Math.sqrt(3));
			try2 = rotate(try2, -2*Math.PI/3);
			try2 = translate(try2, 0, -10*Math.sqrt(3));
			double best = Math.min(dist(pt1, try1), dist(pt1, try2));

			// Top left.
			double[] try3 = translate(try2, -15 ,15*Math.sqrt(3));
			best = Math.min(best, dist(pt1, try3));

			// Top right.
			double[] try4 = translate(try1, 15, 15*Math.sqrt(3));
			best = Math.min(best, dist(pt1, try4));

			// Middle left.
			double[] try5 = translate(pt2, -15, 5*Math.sqrt(3));
			best = Math.min(best, dist(pt1, try5));

			// Middle right.
			double[] try6 = translate(pt2, 15, 5*Math.sqrt(3));
			return Math.min(best, dist(pt1, try6));
		}

		return dist(pt1, pt2);
	}

	public static double dist(double[] pt1, double[] pt2) {
		return Math.sqrt(Math.pow(pt1[0]-pt2[0],2) + Math.pow(pt1[1]-pt2[1],2));
	}
}