string
题号:NC14612
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Bob has a dictionary with N words in it. There are M operators. Each operator is one of two kinds.

 

1. Add a string to the dictionary. It is guaranteed that the string s was not added before.

2. For the given string s find the number of occurrences of the strings from the dictionary. If some string p from the dictionary has several occurrences in s you should count all of them.

输入描述:

The first line of the input gives the number of test cases T(T<=10); T test cases follow.
Each test case contains two integer N( 1≤N≤10^5) and M(1≤M≤10^5), The number of words in the dictionary initially, and the number of operators.
Next N line, each line has a string Wi, represents the ith word in the dictionary (0<|Wi|≤100000)
Next M line, each line contains integer t (1≤t≤2) and nonempty string s—the kind of the operator and the string to process. All strings consist of only lowercase English letters.
The sum of lengths of all strings in the input will not exceed 3*10^6.
For each operator of the second kind print the only integer c—the desired number of occurrences in the string s.

输出描述:

For each operator of the second kind print the only integer c—the desired number of occurrences in the string s.
示例1

输入

复制
2
1 3
abc
2 abcabc
1 aba
2 abababc
2 6
abc
bcd
2 abcd
2 bcd
1 abcd
2 abcd
2 abc
2 bcd

输出

复制
2
3
2
1
3
1
1