#include #include #include using namespace std; int main(void) { ios::sync_with_stdio(false); int T; cin >> T; for (int t = 1; t <= T; ++ t) { int n, m, k; cin >> n >> m >> k; vector s(n); for (int i = 0; i < n; ++ i) { cin >> s[i]; } int ans = 0; for (int i = 1; i < (1< vis; vector id(m, false); for (int j = 0; j < m; ++ j) if ((i>>j) & 1) { id[j] = true; } for (int j = 0; j < n; ++ j) { int x = 0; for (int l = 0; l < m; ++ l) { if (id[l]) x = (x << 1) | (s[j][l] == 'A'); } ++ vis[x]; } int cnt = 0, tot = n; for (auto &p: vis) { tot -= p.second; cnt += p.second * tot; } if (cnt >= k) ++ ans; } cout << "Case #" << t << ": " << ans << endl; } return 0; }