1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstdlib>
 4 #include<cstring>
 5 #include<ctime>
 6 #include<cmath>
 7 #include<algorithm>
 8 using namespace std;
 9 #define MAXN 110
10 #define mod 10007
11 struct node{int v,fail,Link[26];}tr[MAXN*60];
12 int n,m,len,ans,mul(1),q[MAXN*60],f[MAXN][MAXN*60];
13 char ch[MAXN];
14 inline int read()
15 {
16     int x=0,f=1;  char ch=getchar();
17     while(!isdigit(ch))  {if(ch==‘-‘)  f=-1;  ch=getchar();}
18     while(isdigit(ch))  {x=x*10+ch-‘0‘;  ch=getchar();}
19     return x*f;
20 }
21 void insert(int k,int x)
22 {
23     int dex=ch[k]-‘A‘;
24     if(!tr[x].Link[dex]) tr[x].Link[dex]=++len;
25     int y=tr[x].Link[dex];
26     if(k==strlen(ch+1))  {tr[y].v++;  return;}
27     insert(k+1,y);
28 }
29 void build()
30 {
31     int head=0,tail=1;
32     while(++head<=tail)
33     {
34         int x=q[head];
35         for(int i=0;i<26;i++)
36             if(tr[x].Link[i])
37             {
38                 int y=tr[x].Link[i];
39                 q[++tail]=y;
40                 if(!x) continue;
41                 int temp=tr[x].fail;
42                 while(temp&&!tr[temp].Link[i])  temp=tr[temp].fail;
43                 tr[y].fail=tr[temp].Link[i];
44                 if(tr[tr[temp].Link[i]].v) tr[y].v=1;
45             }
46     }
47 }
48 void dp()
49 {
50     f[0][0]=1;
51     for(int i=1;i<=m;i++)
52         for(int j=0;j<=len;j++)
53             if(f[i-1][j]&&(!tr[j].v))
54                 for(int k=0;k<26;k++)
55                 {
56                     int temp=j;
57                     while(temp&&!tr[temp].Link[k]) temp=tr[temp].fail;
58                     temp=tr[temp].Link[k];
59                     if(!tr[temp].v)  f[i][temp]=(f[i][temp]+f[i-1][j])%mod;
60                 }
61 }
62 int main()
63 {
64     //freopen("cin.in","r",stdin);
65     //freopen("cout.out","w",stdout);
66     n=read();  m=read();
67     for(int i=1;i<=n;i++){scanf("%s",ch+1);insert(1,0);}
68     build();
69     dp();
70     for(int i=0;i<=len;i++)  ans=(ans+f[m][i])%mod;
71     for(int i=1;i<=m;i++)  mul=(mul*26)%mod;
72     printf("%d\n",(mul-ans+mod)%mod);
73     return 0;
74 }