#include #include #include using namespace std; int tot[1 << 10], q[1010]; int main() { int t, cas = 1; scanf("%d", &t); while (t--) { int n, m, k, ans = 0; scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < n; ++i){ char s[11]; scanf("%s", s); q[i] = 0; for (int j = 0; j < m; ++j) q[i] += (s[j] - 'A') * (1 << j); } for (int i = 0; i < (1 << m); ++i) { memset(tot, 0, sizeof(tot)); for (int j = 0; j < n; ++j) { tot[q[j] & i]++; } int tmp = 0; for (int j = 0; j < (1 << m); ++j) { tmp += tot[j] * (n - tot[j]); } if (tmp >= 2 * k) ++ans; } printf("Case #%d: %d\n",cas++, ans); } return 0; }