A string is a finite sequence of symbols that are chosen from an alphabet. In this problem you are given a string T and nqueries each with a string Pi, where the strings contain lower case English alphabets only. You have to find the number of times Pi occurs as a substring of T.
Input
Input starts with an integer T (≤ 10), denoting the number of test cases.
Each case starts with a line containing an integer n (1 ≤ n ≤ 500). The next line contains the string T (1 ≤ |T| ≤ 106). Each of the next n lines contains a string Pi (1 ≤ |Pi| ≤ 500).
Output
For each case, print the case number in a single line first. Then for each string Pi
Substring Frequency (II) LightOJ - 1427 (AC自动机)
![](https://img-home.csdnimg.cn/images/20240711042549.png)