#include<bits/stdc++.h>
#define RG register
#define il inline
#define N 60010
using namespace std;
int ch[N][27],f[N],cc,n,k;
char s[N*2];
bool in[N];
void Insert(){
int now=0,len=strlen(s+1);int h=1;
while(h<=len){
int c=s[h]-‘A‘;
if(!ch[now][c])ch[now][c]=++cc;
now=ch[now][c];h++;
}in[now]=true;
}
il void getfail(){queue<int>que;
while(!que.empty())que.pop();que.push(0);
while(!que.empty()){
RG int u=que.front();
for(RG int i=0;i<26;++i){
if(ch[u][i])que.push(ch[u][i]),f[ch[u][i]]=(u==0?0:ch[f[u]][i]);
else ch[u][i]=(u==0?0:ch[f[u]][i]);
}
in[u]|=in[f[u]];
que.pop();
}return;
}
#define MOD 10007
int qpow(int a,int b){
if(b==1)return a;if(!b)return 1;
int tmp=qpow(a,(b>>1));
tmp=(tmp*tmp)%MOD;if(b&1)tmp=(tmp*a)%MOD;
return tmp;
}
int dp[101][N];
int main(){
freopen("1.in","r",stdin);
freopen("1.out","w",stdout);
scanf("%d%d",&n,&k);
for(int i=1;i<=n;++i)scanf("%s",s+1),Insert();getfail();
dp[0][0]=1;
for(int i=1;i<=k;++i)
for(int j=0;j<=cc;++j)
if(!in[j]){
for(int K=0;K<26;++K){
dp[i][ch[j][K]]+=dp[i-1][j];
if(dp[i][ch[j][K]]>=MOD)dp[i][ch[j][K]]-=MOD;
}
}int ans=qpow(26,k);
for(int i=0;i<=cc;++i)if(!in[i])ans-=(dp[k][i]%MOD),ans=(ans+MOD)%MOD;
cout<<ans;
return 0;
}