#include using namespace std; int n, m, K; vector a; map b; void work() { cin >> n >> m >> K; a.clear(); for (int i = 1; i <= n; i++) { string x; cin >> x; int y = 0; for (auto v : x) { y = y << 1 | (v == 'A' ? 0 : 1); } a.push_back(y); } int ans = 0; for (int i = 1; i < (1 << m); i++) { b.clear(); for (auto j : a) { int x = 0; for (int k = 0; k < m; k++) { if ((i >> k) & 1) x = x << 1 | ((j >> k) & 1); } b[x]++; } long long y = 0; for (auto j : b) { y += j.second * (n - j.second); } y /= 2; if (y >= K) ans++; } printf("%d\n", ans); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int T; cin >> T; for (int i = 1; i <= T; i++) { printf("Case #%d: ", i); work(); } }