str=[]
a=raw_input().split(" ")
num1=int(a[0])
num=int(a[1])
abc=["A","B","C","D","E","F","G","H"] for i in range(num1):
s=raw_input()
str.append(s) if len(s)==1:
abc.remove(s)
snum=[]
snum.append(0) def f(n,str1):
str1+=n for i in range(num1): if str1.find(str[i])!=-1: return if len(str1)==num:
snum[0]+=1 return for zi in abc:
f(zi,str1)
f("","") print snum[0]%100007