#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rp(i,a,n) for(int i=a;i<=int(n);i++)
#define IT(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define sc(x) scanf("%d", &x)
#define oo INT_MAX
#define fill(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define mod 1000000007
#define N 100005
using namespace std;
int dh[4] = {0, 1, 0, -1};
int dv[4] = {-1, 0, 1, 0};
//code
int a[50][50],s,n,ans,t;
bool ok(int x,int y)
{
if(x<0||y<0||x>=n||y>=n) return false;
return true;
}
void dfs(int x,int y,int c,int ss,int mask)
{
if(!ok(x,y)||ans<c||ss>t) return ; // make sure current cost is not less than the min cost already found
if(x==0&&y==n-1&&ss>=s) { ans=min(ans,c);return; }
int z=a[x][y];
if(z&&!(mask&(1<<z))) {ss++;mask=mask | (1 << z);} // make sure that z is not taken before
dfs(x+1,y,c+1,ss,mask);
dfs(x,y+1,c+1,ss,mask);
dfs(x-1,y,c+1,ss,mask);
dfs(x,y-1,c+1,ss,mask);
}
int main()
{
int x,y,cas=0;
while(1)
{
scanf("%d %d %d",&n,&t,&s);
if(!n&&!t&&!s) break;
rep(i,35)rep(j,35) a[i][j]=0;ans=905;
rep(i,t) { cin >> x >> y ; a[n-1-x][y]=i+1; } // mark each treasure with a number i (1..t)
dfs(n-1,0,0,0,0);
printf("Case %d: %d\n",++cas,ans);
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgbXAgbWFrZV9wYWlyCiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgdmkgdmVjdG9yPGludD4KI2RlZmluZSBwaWkgcGFpcjxpbnQsaW50PgojZGVmaW5lIHZpaSB2ZWN0b3I8cGlpPgojZGVmaW5lIHJlcChpLG4pIGZvcihpbnQgaSA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