#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(arr,x) memset(arr,x,sizeof(arr))
#define rep(i,s,e) for(i=s;i<=e;i++)
#define rrep(i,s,e) for(i=s;i>=e;i--)
string st[110];
ll N, M, res;
ll dp[110][110][110];
bool check[110][110][110];
ll func( ll row, ll col, ll K )
{
if( K==0 )
{
return 0;
}
if( dp[row][col][K]!=-1 )
{
return dp[row][col][K];
}
ll i, j, ans = 0, val = 0;
for(i=0; (row+i)<=N; i++)
{
if( (col-i)>=1 && (col+i)<=M && check[row+i][col-i][col+i] )
{
val += (2*i)+1;
ll opop = -1, opop2;
for(j=(col-i); j<=(col+i); j++)
{
opop2 = -1;
if( (row+i)<N && st[row+1+i][j]=='#' )
{
opop2 = func(row+i+1, j, K-1);
}
opop = max(opop, opop2);
}
if( opop>0 )
ans = max(ans, val+opop);
}
else
{
break;
}
}
if( K==1 )
{
ans = max(ans, val);
}
dp[row][col][K] = ans;
return dp[row][col][K];
}
int main()
{
ll i, j, k, K, T, ppll;
cin >> T;
rep(ppll, 1, T)
{
res = 0;
mset(check, 0);
mset(dp, -1);
cin >> N >> M >> K;
rep(i, 1, N)
{
cin >> st[i];
st[i] = "@" + st[i];
}
rep(i, 1, N)
{
rep(j, 1, M)
{
rep(k, j, M)
{
if( j!=k )
{
check[i][j][k] = (check[i][j][k-1] && (st[i][k]=='#'));
}
else
{
check[i][j][k] = (st[i][k]=='#');
}
}
}
}
rep(i, 1, N)
{
rep(j, 1, M)
{
if( st[i][j]=='#' )
{
func(i, j, K);
res = max(res, dp[i][j][K]);
}
}
}
cout << "Case #" << ppll << ": ";
cout << res << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIG1zZXQoYXJyLHgpIG1lbXNldChhcnIseCxzaXplb2YoYXJyKSkKI2RlZmluZSByZXAoaSxzLGUpIGZvcihpPXM7aTw9ZTtpKyspCiNkZWZpbmUgcnJlcChpLHMsZSkgZm9yKGk9cztpPj1lO2ktLSkKCnN0cmluZyBzdFsxMTBdOwpsbCBOLCBNLCByZXM7CmxsIGRwWzExMF1bMTEwXVsxMTBdOwpib29sIGNoZWNrWzExMF1bMTEwXVsxMTBdOwpsbCBmdW5jKCBsbCByb3csIGxsIGNvbCwgbGwgSyApCnsKICAgIGlmKCBLPT0wICkKICAgIHsKICAgICAgICByZXR1cm4gMDsKICAgIH0KICAgIGlmKCBkcFtyb3ddW2NvbF1bS10hPS0xICkKICAgIHsKICAgICAgICByZXR1cm4gZHBbcm93XVtjb2xdW0tdOwogICAgfQoKICAgIGxsIGksIGosIGFucyA9IDAsIHZhbCA9IDA7CiAgICBmb3IoaT0wOyAocm93K2kpPD1OOyBpKyspCiAgICB7CiAgICAgICAgaWYoIChjb2wtaSk+PTEgJiYgKGNvbCtpKTw9TSAmJiBjaGVja1tyb3craV1bY29sLWldW2NvbCtpXSApCiAgICAgICAgewogICAgICAgICAgIHZhbCArPSAoMippKSsxOwogICAgICAgICAgIGxsIG9wb3AgPSAtMSwgb3BvcDI7CiAgICAgICAgICAgZm9yKGo9KGNvbC1pKTsgajw9KGNvbCtpKTsgaisrKQogICAgICAgICAgIHsKICAgICAgICAgICAgICBvcG9wMiA9IC0xOwogICAgICAgICAgICAgIGlmKCAocm93K2kpPE4gJiYgc3Rbcm93KzEraV1bal09PScjJyApCiAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgb3BvcDIgPSBmdW5jKHJvdytpKzEsIGosIEstMSk7CiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIG9wb3AgPSBtYXgob3BvcCwgb3BvcDIpOwogICAgICAgICAgIH0KICAgICAgICAgICBpZiggb3BvcD4wICkKICAgICAgICAgICAgICBhbnMgPSBtYXgoYW5zLCB2YWwrb3BvcCk7CiAgICAgICAgfQogICAgICAgIGVsc2UKICAgICAgICB7CiAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgfQogICAgaWYoIEs9PTEgKQogICAgewogICAgICAgIGFucyA9IG1heChhbnMsIHZhbCk7CiAgICB9CgogICAgZHBbcm93XVtjb2xdW0tdID0gYW5zOwogICAgcmV0dXJuIGRwW3Jvd11bY29sXVtLXTsKfQppbnQgbWFpbigpCnsKICAgIGxsIGksIGosIGssIEssIFQsIHBwbGw7CgogICAgY2luID4+IFQ7CiAgICByZXAocHBsbCwgMSwgVCkKICAgIHsKICAgICAgIHJlcyA9IDA7CiAgICAgICBtc2V0KGNoZWNrLCAwKTsKICAgICAgIG1zZXQoZHAsIC0xKTsKCiAgICAgICBjaW4gPj4gTiA+PiBNID4+IEs7CiAgICAgICByZXAoaSwgMSwgTikKICAgICAgIHsKICAgICAgICAgICBjaW4gPj4gc3RbaV07CiAgICAgICAgICAgc3RbaV0gPSAiQCIgKyBzdFtpXTsKICAgICAgIH0KCiAgICAgICByZXAoaSwgMSwgTikKICAgICAgIHsKICAgICAgICAgICByZXAoaiwgMSwgTSkKICAgICAgICAgICB7CiAgICAgICAgICAgICAgIHJlcChrLCBqLCBNKQogICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICBpZiggaiE9ayApCiAgICAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgIGNoZWNrW2ldW2pdW2tdID0gKGNoZWNrW2ldW2pdW2stMV0gJiYgKHN0W2ldW2tdPT0nIycpKTsKICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgY2hlY2tbaV1bal1ba10gPSAoc3RbaV1ba109PScjJyk7CiAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgIH0KICAgICAgICAgICB9CiAgICAgICB9CgogICAgICAgcmVwKGksIDEsIE4pCiAgICAgICB7CiAgICAgICAgICAgcmVwKGosIDEsIE0pCiAgICAgICAgICAgewogICAgICAgICAgICAgICBpZiggc3RbaV1bal09PScjJyApCiAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgIGZ1bmMoaSwgaiwgSyk7CiAgICAgICAgICAgICAgICAgICByZXMgPSBtYXgocmVzLCBkcFtpXVtqXVtLXSk7CiAgICAgICAgICAgICAgIH0KICAgICAgICAgICB9CiAgICAgICB9CgogICAgICAgY291dCA8PCAiQ2FzZSAjIiA8PCBwcGxsIDw8ICI6ICI7CiAgICAgICBjb3V0IDw8IHJlcyA8PCBlbmRsOwogICAgfQoKICAgIHJldHVybiAwOwp9Cg==