#include #include #include #include #include #include #include #include using namespace std; typedef long long LL; typedef unsigned int UINT32; int calc() { int n, m, k; cin >> n >> m >> k; string s; vector resnums(1 << m); vector answers(n); for (int i = 0; i < n; ++i) { cin >> s; int v = 0; for (int j = 0; j < m; ++j) { v <<= 1; v |= (s[j] == 'B'); } answers[i] = v; for (int j = 0; j < i; ++j) { ++resnums[answers[j] ^ v]; } } int ans = 0; for (int i = 1; i < (1 << m); ++i) { int num = 0; for (int j = 1; j < (1 << m); ++j) { if (i & j) { num += resnums[j]; } } ans += (num >= k); } return ans; } int main(void) { int N; cin >> N; // NOTE: if using getline() to read the input, the following two lines should be // added to read the line sepeartor in the first line. //string line; //getline(cin, line); for (int i=1; i<=N; ++i) { cout << "Case #" << i << ": " << calc() << endl; } return 0; }