#pragma comment(linker, "/STACK:1024000000,1024000000") #include #include #include #include #include #include #include #include #include #include #include #include #include #define INF 0X3F3F3F3F #define N 200005 #define M 200005 #define LL long long #define ULL unsigned long long #define FF(i, a, b) for(int i = a; i <= b; ++i) #define RR(i, a, b) for(int i = a; i >= b; --i) #define FJ(i, a, b) for(int i = a; i < b; ++i) #define SC(x) scanf("%d", &x) #define SCC(x, y) scanf("%d%d", &x, &y) #define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z) #define SS(x) scanf("%s", x) #define PR(x) printf("%d\n", x) #define PII pair #define PLL pair #define MP make_pair #define PB push_back #define IN freopen("in.txt", "r", stdin) #define OUT freopen("out.txt", "w", stdout) using namespace std; inline void II(int &n){char ch = getchar(); n = 0; bool t = 0; for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1; for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;} inline void OO(int a){if(a < 0) {putchar('-'); a = -a;} if(a >= 10) OO(a / 10); putchar(a % 10 + '0');} const long double eps = 1e-8; int sgn(long double x){ return (x > eps) - (x < -eps); } int n, m, k, a[N]; char str[1005][15]; int b[N]; int main(){ // IN; int _; SC(_); FF(CA, 1, _){ int ans = 0; SCCC(n, m, k); FF(i, 1, n){ a[i] = 0; SS(str[i]); for(int j = 0; j < m; ++j){ if(str[i][j] == 'A') a[i] |= 1 << j; } } for(int s = 0; s < 1 << m; ++s){ memset(b, 0, 1024 << 2); int cnt = 0; for(int i = 1; i <= n; ++i) ++b[s & a[i]]; for(int i = 0; i < 1024; ++i) cnt += b[i] * (n - b[i]); cnt /= 2; if(cnt >= k) ++ans; } printf("Case #%d: %d\n", CA, ans); } return 0; }