#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MOD 1000003
#define mod(x) (((x) >= MOD) ? ((x) - MOD) : (x))
#define match(a, b) ((a) == '?' || (b) == '?' || (a) == (b))
int T, N, M, K;
int Dp[55][1 << 15], AndV[55][26];
char P[15][64];
int main(void){
freopen("set.in", "r", stdin);
freopen("set.out", "w", stdout);
for (scanf("%d", &T); T; T --){
scanf("%d%d", &M, &K);
for (int i = 0; i < M; i ++) scanf("%s", P[i]);
N = strlen(P[0]);
memset(Dp, 0, sizeof(Dp));
Dp[0][(1 << M) - 1] = 1;
for (int i = 0; i < N; i ++){
for (int j = 'a'; j <= 'z'; j ++){
AndV[i][j] = 0;
for (int k = 0; k < M; k ++)
if (match(P[k][i], j)) AndV[i][j] += (1 << k);
}
}
for (int i = 0; i < N; i ++){
for (int j = 0; j < (1 << M); j ++){
if (Dp[i][j]){
for (int k = 'a'; k <= 'z'; k ++){
int nj = j & AndV[i][k];
Dp[i + 1][nj] = mod(Dp[i + 1][nj] + Dp[i][j]);
}
}
}
}
int ans = 0;
for (int i = 0; i < (1 << M); i ++){
int count = 0;
for (int j = 0; j < M; j ++) count += ((i >> j) & 1);
if (count == K) ans = mod(ans + Dp[N][i]);
}
printf("%d\n", ans);
}
return 0;
}