// Arup Guha
// Finished on 2/2/2016
// Solution to 2010 World Finals Problem I: Robots on Ice

import java.util.*;

public class i {

	// Possible direction movements.
	final public static int[] DX = {-1,0,0,1};
	final public static int[] DY = {0,-1,1,0};

	// Store input data here.
	public static int r;
	public static int c;
	public static int[] checkPts;

	// Memoize some stuff to speed up the code.
	public static HashMap<String,Long> map;
	public static HashMap<String,Boolean> stuckMap;

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		r = stdin.nextInt();
		c = stdin.nextInt();
		int loop = 1;

		// Process each case.
		while (r != 0) {

			// Read in check points - store as one number.
			checkPts = new int[3];
			for (int i=0; i<3; i++) {
				checkPts[i] = stdin.nextInt();
				checkPts[i] = c*checkPts[i] + stdin.nextInt();
			}

			// Store results here.
			map = new HashMap<String,Long>();
			stuckMap = new HashMap<String,Boolean>();

			// Output result.
			System.out.println("Case "+loop+": "+go(1, 0));

			// Get next case.
			r = stdin.nextInt();
			c = stdin.nextInt();
			loop++;
		}
	}

	// Returns the result for all possible paths where mask squares have been visited and cur is the current square.
	public static long go(long mask, int cur) {

		// Look up result.
		String key = mask+":"+cur;
		if (map.containsKey(key)) return map.get(key);
		int len = Long.bitCount(mask);

		// Hit a checkpoint too early.
		if ( (  (mask & (1L<<checkPts[0])) > 0) && len < (r*c)/4) return 0L;
		if ( (  (mask & (1L<<checkPts[1])) > 0) && len < (r*c)/2) return 0L;
		if ( (  (mask & (1L<<checkPts[2])) > 0) && len < (3*r*c)/4) return 0L;
		if (len < r*c && cur == 1) return 0L;

		// Too far to get to the next check point.
		if (len < (r*c)/4 && steps(cur, checkPts[0]) > (r*c)/4 - len) return 0L;
		if (len < (r*c)/2 && steps(cur, checkPts[1]) > (r*c)/2 - len) return 0L;
		if (len < (3*r*c)/4 && steps(cur, checkPts[2]) > (3*r*c)/4 - len) return 0L;

		// Basic base cases for checkpoints.
		if (len == (r*c)/4 && cur != checkPts[0]) return 0L;
		if (len == (r*c)/2 && cur != checkPts[1]) return 0L;
		if (len == (3*r*c)/4 && cur != checkPts[2]) return 0L;

		// Success!!!
		if (len == r*c && cur == 1) return 1L;

		// See if the region of unmarked squares isn't contiguous, or if a "cave" has been formed
		// (square you can go into but can't get out of)
		if (stuck(mask, 1)) return 0L;
		if (inCave(mask, cur)) return 0L;

		// Add # routes by traveling in each possible direction from cur.
		long res = 0L;
		for (int i=0; i<DX.length; i++) {
			int nextx = cur/c + DX[i];
			int nexty = cur%c + DY[i];
			int next = nextx*c + nexty;
			if (inbounds(nextx, nexty) && off(mask, next))
				res += go(mask | (1L<<next), next);
		}

		// Store the result and return.
		map.put(key, res);
		return res;
	}

	// Wrapper function for dfs from cur.
	public static boolean stuck(long mask, int cur) {
		long newmask = dfs(mask, cur);
		boolean res = Long.bitCount(newmask) < r*c;
		return res;
	}

	// Run a DFS from cur on mask, returning the filled in mask.
	public static long dfs(long mask, int cur) {

		long newmask = mask | (1L<<cur);

		// Go all directions and recurse on unfilled squares.
		for (int i=0; i<DX.length; i++) {
			int nextx = cur/c + DX[i];
			int nexty = cur%c + DY[i];
			int next = nextx*c + nexty;
			if (inbounds(nextx, nexty) && off(newmask, next))
				newmask = dfs(newmask, next);
		}

		// End result.
		return newmask;
	}

	// Returns true iff there exists a square that is a cave. A cave is an unvisited square with only once adjacent
	// unvisited square where the original square isn't adjacent to current. Thus, if we were to get to this square
	// we'd have to go through that adjacent square and we wouldn't be able to get out...
	public static boolean inCave(long mask, int cur) {

		// Check each bit that is off.
		for (int i=0; i<r; i++) {
			for (int j=0; j<c; j++) {

				// Can't be a cave.
				if (i==0 && j == 1) continue;

				// Check if this bit that is off is a cave spot.
				if (off(mask, i*c+j)) {

					int neighbors = 0;
					for (int k=0; k<DX.length; k++)
						if (inbounds(i+DX[k], j+DY[k]) && off(mask, (i+DX[k])*c + j+DY[k] ))
							neighbors++;

					// Two ways in which this location can be a cave.
					if (neighbors == 0) return true;
					if (neighbors == 1 && steps(cur, i*c+j) > 1) return true;
				}
			}
		}

		// If we get here, we didn't find a cave.
		return false;
	}

	// Returns the Manhattan distance between pos1 and pos2.
	public static int steps(int pos1, int pos2) {
		return Math.abs(pos1/c - pos2/c) + Math.abs(pos1%c-pos2%c);
	}

	public static boolean inbounds(int x, int y) {
		return x >= 0 && x < r && y >= 0 && y < c;
	}

	public static boolean off(long mask, int bit) {
		return ((1L << bit) & mask) == 0;
	}
}