#include<cstdio>
#include<cstring>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;
int dp[36][36][36][36],x[500],y[500],n,m,k;
int dfs(int x1,int y1,int x2,int y2){
int &t = dp[x1][y1][x2][y2];
if(t != -1) return t;
int ans=0;
for(int i = 0;i < k;i++){
if(x[i] > x1 && x[i] <= x2 && y[i] > y1 && y[i] <= y2)
ans++;
}
if(ans == 0) return t=INF;
if(ans == 1) return t=0;
t=INF;
for(int i = x1+1;i < x2;i++){
t=min(t,dfs(x1,y1,i,y2) + dfs(i,y1,x2,y2) + y2-y1);
}
for(int i = y1+1;i < y2;i++){
t=min(t,dfs(x1,y1,x2,i) + dfs(x1,i,x2,y2) + x2-x1);
}
return t;
}
int main(){
int t=1;
while(scanf("%d%d%d",&n,&m,&k) == 3){
for(int i = 0;i < k; i++) scanf("%d%d",&x[i],&y[i]);
memset(dp,-1,sizeof(dp));
printf("Case %d: %d\n",t++,dfs(0,0,n,m));
}
}
08-24