#include using namespace std; const int maxn = 1029; int T, n, m, k; int a[maxn], cnt[maxn]; int main() { scanf("%d", &T); for (int kase = 1; kase <= T; ++kase) { scanf("%d%d%d", &n, &m, &k); char s[20]; for (int i = 1; i <= n; ++i) { a[i] = 0; scanf("%s", s); for (int j = 0; j < m; ++j) a[i] |= ((s[j] - 'A') << j); } int ans = 0; for (int i = 0; i < (1 << m); ++i) { memset(cnt, 0, sizeof cnt); for (int j = 1; j <= n; ++j) { ++cnt[a[j] & i]; } int pairs = 0; for (int S = i; S; S = (S - 1) & i) pairs += cnt[S] * (n - cnt[S]); pairs += cnt[0] * (n - cnt[0]); pairs >>= 1; if (pairs >= k) ++ans; } printf("Case #%d: %d\n", kase, ans); } return 0; }