Ben Zynoulus lives in a city in Meashara. He travels around only by subway. Each subway line is a cycle, thus if you enter at station , you will reach , then , ..., , then you return to , then to , and so on.
Each subway line is unidirectional: you can go from to , but not from to . In some cases there might be another subway line which goes from to ; however, Ben has a rule that, after going from to , he never goes back directly to .
As every subway user, Ben has a card to pay for his tickets, and this card notes the number of stations travelled so far, over all his lifetime. Now, Ben has a question: how many possible routes could he have taken, according to his rules? If there are two subway lines which go from to , then he considers routes using them distinct.
Each subway station has a code, which is a lowercase letter of the English alphabet.
The first line contains (), the number of subway routes, and (), the number of stations travelled so far. Each of the following lines contains a description of one subway route, as a string. These are codes of consecutive stations of the given route.
Output the number of possible routes modulo 1000007.
In this case Ben can travel either a-b-c-d-e-a-..., or e-d-c-b-a-e-... He cannot change between these two options, since he would break his rule. However, in the first case, he can change the subway line he is using after each station. This gives us possible routes in total.
Input
3 10 abcde abcde edcba
Output
5125