#include using namespace std; const int maxn = 1 << 11; long long cnt[maxn]; int a[maxn]; char str[maxn]; int main() { int T; scanf("%d", &T); for (int c = 1; c <= T; c++) { int n, m, k; scanf("%d%d%d", &n, &m, &k); int mx = 1 << m; for (int i = 0; i < n; i++) { scanf("%s", str); a[i] = 0; for (int j = 0; j < m; j++) { a[i] <<= 1; a[i] |= str[j] - 'A'; } } int ans = 0; for (int i = 0; i < mx; i++) { memset(cnt, 0, sizeof(cnt)); for (int j = 0; j < n; j++) { cnt[a[j] & i]++; } long long all = (long long)n * (n - 1) / 2; for (int j = 0; j < mx; j++) { all -= cnt[j] * (cnt[j] - 1) / 2; } // printf("%I64d\n", all); if (all >= k) { ans++; } } printf("Case #%d: %d\n", c, ans); } return 0; }