Problem N. Microgene
时间限制 1000 ms
内存限制 64 MB
sevenzero is very interesting in Bioinformation and have done some research on it. One day, sevenzero found a phenomenon called Microgene. Microgene is a special fragment in the DNA, and different Microgenes may have the same hereditary effect. Microgene works if and only if there are more than one Microgenes(Microgenes may overlap) with the same hereditary effect in the DNA. To finish his paper, sevenzero wants to know how many different DNAs with length L which contain the hereditary effect caused by Microgenes.
To simplify the problem, a DNA or a Microgene is considerd as a string consisting of character 'A', 'T', 'C' and 'G'. And a Microgene is in the DNA if the Microgene string is the substring of the DNA string. All Microgenes given are different and with the same hereditary effect.
输入数据
输出数据
One line for each case, the answer modulo 10007.
样例输入
复制
2 3
AT
TC
2 3
ATC
T
3 1000000
ATCG
TCGT
CTAG
样例输出
$ Mathjax font initiator $