#P2167. [SDOI2009] Bill的挑战
[SDOI2009] Bill的挑战
Description
Sheng_bill not only has amazing mental arithmetic, but can also easily handle various statistics. In yesterday's contest, you tied with him thanks to your excellent program, which made Sheng_bill extremely displeased. So he challenges you again. This time, you must not lose.
The rules are as follows:
Given strings of the same length (composed of lowercase English letters and ?), , count the number of strings that match exactly of these strings. Output the answer modulo .
A string () matches if the following conditions hold:
- .
- For any , either or .
Here contains only lowercase English letters.
Input Format
This problem contains multiple test cases.
The first line contains an integer , the number of test cases.
For each test case, the first line contains two integers, and .
The next lines each contain a string .
Output Format
For each test case, output a single line with one integer, the answer.
5
3 3
???r???
???????
???????
3 4
???????
?????a?
???????
3 3
???????
?a??j??
????aa?
3 2
a??????
???????
???????
3 2
???????
???a???
????a??
914852
0
0
871234
67018
Hint
Constraints and Conventions:
- For of the testdata, , .
- For of the testdata, , .
- For of the testdata, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号