#include using namespace std; const int maxn = 1e3 + 50; char s[maxn][15]; int vis[3000]; int main(){ int t; int T = 1; scanf("%d", &t); while (T <= t) { int n, m, k; scanf("%d%d%d", &n, &m, &k); memset(s, 0, sizeof(s)); int temp[maxn]; for (int i = 1; i <= n; i++) scanf("%s", s[i]); int ans = 0; for (int i = 1; i < (1 << m); i++) { memset(temp, 0, sizeof(temp)); memset(vis, 0, sizeof(vis)); for (int j = 1; j <= n; j++) { int ti = i; int cnt = 0; while(ti > 0) { int ww = ti % 2; if (ww == 1) { temp[j] <<= 1; temp[j] += (s[j][cnt] - 'A'); } cnt++; ti /= 2; } vis[temp[j]]++; } int total = 0; for (int j = 1; j <= n; j++) { if (vis[temp[j]] == 0) continue; int num = vis[temp[j]]; total += num * (num - 1); //printf("temp i %d j %d %d\n", i, j, mp[temp[j]]); vis[temp[j]] = 0; } int tt = n * (n - 1) - total; /* int sum = 0; for (int j = 1; j <= n; j++) { for (int k = j + 1; k <= n; k++) { if (j == k) continue; if (temp[j] ^ temp[k] != 0) { sum++; } } } */ //printf("i %d sum %d\n", i, sum); //printf("tt %d\n", tt); if (tt >= k * 2) ans++; } printf("Case #%d: ", T);T++; printf("%d\n", ans); } return 0; } /* 99 10 10 1 AAAAAAAAAA BBBBBBBBBB AAAAAAAAAA BBBBBBBBBB AAAAAAAAAA BBBBBBBBBB AAAAAAAAAA BBBBBBBBBB AAAAAAAAAA BBBBBBBBBB */