Given lowercase strings from to , you are to take a substring from each string (substring can be empty), and concatenate them to form a new string . How many distinct strings can you form, modulo ?
Input Specification
The first line will contain , the number of lowercase strings.
The next lines will contain a lowercase string . It is guaranteed that the sum of the length of the strings will not exceed .
Output Specification
Output one integer, representing the number of distinct strings that can be formed, modulo .
Subtasks
Subtask 1 [30%]
The sum of the length of the lowercase strings will not exceed .
Subtask 2 [70%]
No further constraints.
Sample Input 1
2
bbbcc
bb
Sample Output 1
30
Comments