Given

strings

consisting of

,

, or

, you need to answer

queries. In each query, given a string

and interval endpoints

and

, find the value of the following expression:
where
)
denotes the length of the longest common prefix of

and

.
输入描述:
The first line of input contains an integer
(
), denoting the number of test cases.
For each test case, the first line contains two integers
and
(
), denoting the number of strings and the number of queries, respectively.
The next
lines each contain a string
consisting of
,
, or
(
), as described above.
The next
lines each describe a query. Each line contains two integers
and
(
) and a string
consisting of
,
, or
(
), representing the left and right boundaries of the interval to be summed and the query string.
It is guaranteed that the input satisfies
and
.
输出描述:
For each query, output one line containing an integer representing the answer to the query.
示例1
输入
复制
1
4 3
0112
01201
01121
0012
1 3 0112
2 4 11121
3 4 0