#include using namespace std; typedef long long ll; const int maxn = 100000; int t, n, m, k, ans; ll a[maxn + 10]; void fwt() { for (int i = 0; i < m; ++i) for (int j = 0; j < 1 << m; ++j) if (j >> i & 1) { ll x = a[j ^ (1 << i)], y = a[j]; a[j ^ (1 << i)] = x + y; a[j] = x - y; } } void ifwt() { fwt(); for (int i = 0; i < 1 << m; ++i) a[i] >>= m; } void fmt() { for (int i = 0; i < m; ++i) for (int j = 0; j < 1 << m; ++j) if (j >> i & 1) a[j] += a[j ^ (1 << i)]; } int main() { scanf("%d", &t); for (int cas = 1; cas <= t; ++cas) { scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < 1 << m; ++i) a[i] = 0; ans = 0; for (int i = 1; i <= n; ++i) { int now = 0; for (int j = 1; j <= m; ++j) { char c = getchar(); while (!isgraph(c)) c = getchar(); now = now * 2 + (c == 'B'); } ++a[now]; } fwt(); for (int i = 0; i < 1 << m; ++i) a[i] = a[i] * a[i]; ifwt(); a[0] -= n; for (int i = 0; i < 1 << m; ++i) a[i] >>= 1; fmt(); for (int i = 0; i < 1 << m; ++i) if (n * (n - 1) / 2 - a[i] >= k) ++ans; printf("Case #%d: %d\n", cas, ans); } }