#include <iostream>
using namespace std;
int n, m, k;
int arr[100][100];
int visited[100];
int len0[100];
int vung[100];
bool check(int t, int s){
for(int i=1; i<=m; i++){
if(arr[t][i] != arr[s][i])
return false;
}
return true;
}
int Dem0(int s){
int count = 0;
for(int i=1; i<=m; i++){
if(arr[s][i] == 0)
count++;
}
return count;
}
void reset(){
for(int i=1; i<=n; i++){
visited[i] = 0;
}
}
int main(){
//freopen("vao.txt", "r", stdin);
int t;
cin >> t;
for(int tc=1; tc<=t; tc++){
cin >> n >> m >> k;
for(int i=1; i<=n; i++){
for(int j=1; j<=m; j++){
cin >> arr[i][j];
}
}
reset();
int index = 1;
for(int i=1; i<=n; i++){
if(visited[i] == 0){
visited[i] = index;
for(int j=1; j<=n; j++){
if(visited[j] == 0)
if(check(i, j))
visited[j] = index;
}
len0[index] = Dem0(i);
index++;
}
}
for(int i=1; i<index; i++){
int count = 0;
for(int j=1; j<=n; j++){
if(visited[j] == i)
count++;
}
vung[i] = count;
}
/*for(int i=1; i<index; i++){
cout << i << " " << vung[i] << " " << len0[i] << " " << endl;
}*/
int ans = -1;
for(int i=1; i<index; i++){
if((k-len0[i])%2==0){
ans = max(ans, vung[i]);
}
}
cout << "Case #" << tc << " ";
cout << ans << endl;
}
return 0;
}