# UVA1629---Cake slicing

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<stack>
#include<map>
#include<queue>
#include<vector>
using namespace std;
const int maxn = 23;

const int INF = 0x3f3f3f3f;
int dp[maxn][maxn][maxn][maxn],flag[maxn][maxn],sum[maxn][maxn],m,n,k;

//预处理让递归时求矩形有多少个标记时稍微快那么一点点
void getsum(){
memset(sum,0,sizeof sum);
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
sum[i][j] = sum[i][j-1] +flag[i][j];
}
}
}
int findnum(int l,int r,int u,int d){
int ans=0;
for(int i=u;i<=d;i++){
ans += sum[i][r] - sum[i][l-1];
//也是一种小优化,我们需要知道的是是否为空,1,多
// if(ans>=2) return ans;
}
return ans;
}

int dfs(int l,int r,int u,int d){
int &ans = dp[l][r][u][d];
if(ans>=0) return ans;
int num = findnum(l,r,u,d);
if(!num) return ans = INF;
if(num==1) return ans = 0;
ans = INF;
for (int i=l;i<r;i++){
ans = min(dfs(l,i,u,d)+dfs(i+1,r,u,d)+(d-u)+1,ans);
}

for (int i=u;i<d;i++){
ans = min(dfs(l,r,u,i)+dfs(l,r,i+1,d)+(r-l)+1,ans);
}
return ans;
}
int main(){
int kase=0;
int a,b;
while(cin>>m>>n>>k){
memset(dp,-1,sizeof dp);
memset(flag,0,sizeof flag);
for(int i=1;i<=k;i++){
cin>>a>>b;flag[a][b]=1;
}
getsum();
printf("Case %d: %d\n",++kase,dfs(1,n,1,m));
}
return 0;
}