#P7479. [2017年杭电多校]Rikka with String
[2017年杭电多校]Rikka with String
Rikka with String
Problem Description
As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them: Yuta has strings , and he wants to know the number of antisymmetric strings of length which contain all given strings as continuous substrings. A string is antisymmetric if and only if for all . It is too difficult for Rikka. Can you help her? In the second sample, the strings which satisfy all the restrictions are .
Input
The first line contains a number , the number of the testcases. For each testcase, the first line contains two numbers . Then lines follow, each line contains a string .
Output
For each testcase, print a single line with a single number -- the answer modulo 998244353.
Sample Input
2
2 2
011
001
2 3
011
001
Sample Output
1
4
Source
2017 Multi-University Training Contest - Team 5