//* Problem  : 2004 - The Game of Efil
//* Contest  : acm.tju.edu.cn
//* Origin   : ECNA_2005
//* Type     : Solution
//* Date     : 2007.08.28
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0
//* Algoritm : Backtracking

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

int n, m, a[16][16], c[64][64];

void set_cells(int pos, int val)
{
	int x = pos/m, y=pos%m;
	c[x][y] = val;
	c[x+n][y] = val;
	c[x+n+n][y] = val;
	c[x][y+m] = val;
	c[x][y+m+m] = val;
	c[x+n][y+m] = val;
	c[x+n+n][y+m] = val;
	c[x+n][y+m+m] = val;
	c[x+n+n][y+m+m] = val;
}

/// c[pos/m][pos%m] = 0

void incr()
{
	int pos = n * m - 1;
	while (c[pos/m][pos%m]) { set_cells(pos, 0) ; pos--; }
	set_cells(pos, 1);
}

/*
	for (x = 0; x < n; x++)
		for (y = 0; y < m; y++)
		{
			cnt = 0;
			for (dx = -1; dx <= 1; dx++)
				for (dy = -1; dy <= 1; dy++)
					cnt += c[(n+x+dx)%n][(n+y+dy)%m];
			cnt -= c[x][y];
			v = (cnt==2 || cnt==3);
			if (v != a[x][y]) return 0;
		}
*/

int is_ancestor()
{
	int x, y, dx, dy, cnt, v;
	for (x = 0; x < n; x++)
		for (y = 0; y < m; y++)
		{
			cnt = 0;
//			for (dx = -1; dx <= 1; dx++)
//				for (dy = -1; dy <= 1; dy++)
//					cnt += c[n+x+dx][m+y+dy];
			cnt += c[n+x+1][m+y+1];
			cnt += c[n+x+1][m+y-1];
			cnt += c[n+x+1][m+y];
			cnt += c[n+x-1][m+y+1];
			cnt += c[n+x-1][m+y-1];
			cnt += c[n+x-1][m+y];
			cnt += c[n+x][m+y+1];
			cnt += c[n+x][m+y-1];
			v = ((!c[x][y] && cnt==3) || (c[x][y] && (cnt==3 || cnt == 2)));
			//v = (cnt==2 || cnt==3);
			if (v != a[x][y]) return 0;
		}

/*
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
			printf("%d ", c[i][j]);
		printf("\n");
	}
	printf("-------------------\n");
*/
	return 1;
}

int solve()
{
	int i, j, k, res = 0, max2 = (1<<(n*m))-1;
	memset(c, 0, sizeof(c));
	res += is_ancestor();
	for (i = 0; i < max2; i++)
	{
		incr();
		res += is_ancestor();
	}
	return res;
}

int main()
{
	int i, res, t1, t2, it = 0, cnt;
	while (scanf("%d %d", &n, &m) == 2 && n && m)
	{
		memset(a, 0, sizeof(a));
		scanf("%d", &cnt);
		for (i = 0; i < cnt; i++)
		{
			scanf("%d %d", &t1, &t2);
			a[t1][t2] = 1;
		}
		res = solve();
		printf("Case %d: ", ++it);
		if (!res) printf("Garden of Eden.\n");
			else printf("%d possible ancestors.\n", res);
	}
	return 0;
}