You are given strings , each consisting only of uppercase English letters.
Consider choosing some substrings of a string consisting only of uppercase English letters. Each chosen substring must equal one of , and no two chosen substrings may share a character position. A substring consists of consecutive characters. Chosen substrings may be adjacent.
You may choose multiple occurrences of the same string. Even if a string appears more than once among the given strings, the same occurrence in cannot be chosen multiple times.
Let be the maximum number of substrings that can be chosen in this way. If no substring can be chosen, let . For example, if the only given string is , then : choose the first two characters and the last two characters. However, the two occurrences of in share the middle character, so .
Find the sum of over all strings of length consisting only of uppercase English letters, modulo .
The input is given in the following format.
For each test case, output the sum of over all uppercase English strings of length , modulo , on a separate line. Output the answers in the order the test cases appear in the input.
In the first test case, only for ; it is for the other strings.
The first line contains the number of test cases . Each test case is given in the following format.
The first line of each test case contains two integers and , separated by a space. The -th of the following lines contains the string .
| 4 | 37 | No additional constraints. |
In the second test case, is the number of occurrences of in . There are strings whose first character is and whose second character is , giving a sum of . The string contributes twice because .
In the third test case, if the first two characters or the last two characters are , and otherwise. There are such strings. Even for , only one occurrence of can be chosen without overlap.
In the fourth test case, listing twice does not change which substrings can be chosen, so the answer is the same as in the second test case.
In the fifth test case, every occurrence of or in can be chosen. At each position, each of these two letters occurs in strings, giving a sum of .