#include int T; int n, m, k; char s[1000]; int x[2000]; int ans, cnt; int cc[2000]; int main() { scanf("%d", &T); for (int cas = 1; cas <= T; cas++) { scanf("%d%d%d", &n, &m, &k); for (int i = 1; i <= n; i++) { scanf("%s", s + 1); x[i] = 0; for (int j = 1; j <= m; j++) { x[i] = (x[i] << 1) + (s[j] == 'A'); } } ans = 0; for (int i = 1; i < (1 << m); i++) { cnt = 0; for (int j = 1; j <= n; j++) { cnt += j - 1 - cc[x[j] & i]; cc[x[j] & i]++; } for (int j = 1; j <= n; j++) { cc[x[j] & i]--; } if (cnt >= k) { ans++; } } printf("Case #%d: %d\n", cas, ans); } return 0; }