Nowadays, there are a lot of unusual people. We won't go into details, but instead focus on a certain type, to us personally the most interesting people. Of course, we're talking about barbarians!
There are a lot of barbarians, but only a few of them are truly important. This story has
Our barbarians are playing an interesting game with their good friend Tarzan. The game is played in
type: Tarzan shows the word to the barbarians. type: Tarzan asks the barbarian denoted with the following question: "Out of all the words I've shown you so far, how many of them are such that the word on your stone tablet is their consecutive substring?"
Given the fact that the barbarians go wild a lot and aren't really able to pay attention and keep up with what's happening in the game, they need your help. Help the barbarians answer each of Tarzan's questions correctly.
Input
The first line of input contains the integer
Each of the following
After that, the integer
In the case when
The total length of all words written on the barbarians' stone tablets will not exceed
The total length of all words that Tarzan shows the barbarians will not exceed
Output
For each round of a different form, output a single line. The
Scoring
In test cases worth 50% of total points, it will hold
Sample Input 1
3
a
bc
abc
3
1 abca
2 1
2 3
Sample Output 1
1
1
Explanation for Sample Output 1
The only word Tarzan has shown is abca
. The answer to the first question is, of course, a
is a substring of the word abca
. The answer to the second question is also abc
is a substring of the word abca
.
Sample Input 2
7
abba
bbaa
b
bbaa
abba
a
ba
7
1 aaabbabbaab
2 7
1 baabaaa
1 aabbbab
2 3
1 aabba
2 3
Sample Output 2
1
3
4
Comments