How many different words of length exactly can you build by concatening given words? You can use any word as many times as you wish.
Input consists of several cases, each with and , followed by different words. Assume that is between 1 and , that is at least 1, that the words only have lowercase letters, and that the sum of their lenghts is at most 50.
For every case, print the result modulo .
Input
1 3 a deu hol 4 3 a deu hol 100 2 a aa 4 3 a ab ac 8 3 hola lola la 10 3 ab abb bb 10 4 x y yy xyy 32 4 wo lo wolo wololo 3 4 ab c a bc 1000000000000000000 4 ab c a bc
Output
1 5 1 11 11 56 1024 65536 15 382802655