#include <bits/stdc++.h>
using namespace std;
int T,n,m,k;
int answers[1010];
int process_answers[1010];
void replace(string &s){
for (int i=0; i<m; i++){
if (s[i] == ‘A‘) {
s[i] = ‘1‘;
} else if (s[i] == ‘B‘) {
s[i] = ‘0‘;
}
}
}
bool judge(int save_flag) {
// 对于原问题进行保留处理
for (int i=0; i<n; i++) {
process_answers[i] = answers[i] & save_flag;
}
// 统计每一个问题结果出现次数
map<int,int> count_fre;
for (int i=0; i<n; i++) {
if (count_fre.count(process_answers[i]) > 0) {
count_fre[process_answers[i]] += 1;
} else {
count_fre[process_answers[i]] = 1;
}
}
// 利用总对数减去相同问题结果对数
int total = n * (n - 1) / 2;
for (map<int, int>::iterator iter = count_fre.begin(); iter != count_fre.end(); iter++) {
int cnt = iter->second;
if (cnt >= 2) {
total -= (cnt * (cnt - 1) / 2);
}
}
if (total >= k) {
return true;
} else {
return false;
}
}
void print(int casei, int res){
printf("Case #%d: %d\n",casei, res);
}
int main() {
scanf("%d",&T);
for (int casei = 1; casei<=T; casei++) {
scanf("%d%d%d",&n,&m,&k);
for (int i=0; i<n; i++) {
string s;
cin >> s;
replace(s);
bitset<11> bs(s);
answers[i] = bs.to_ulong();
}
int l = 1, r = (1 << m) - 1, res = 0;
for (int i = l; i <= r; i++) {
if (judge(i)) {
res += 1;
}
}
print(casei,res);
}
return 0;
}