#Lutece0008. God Only Knows!
God Only Knows!
Migrated from Lutece 8 God Only Knows!
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
Zplinti1 is given a big and long string , together with a list of strings that are viruses. He wants to find the number of substrings of , so that it does not contain any viruses. Same substrings with different starting positions are regarded as different!
Zplinti1 finds this problem difficult enough, he thinks Only God Can Solve This Problem
, but you don’t think so, right?
Input
The first line of input contains a number , indicating the number of cases. () For each case, the first line is a string , with length no more than . The second line is a number , which is the number of virus strings. Then lines comes, each with a string.
All the strings contains lowercase letters from a
to z
only. The total length of all virus strings in one case will be no more than .
Output
For each case, output Case #i:
first. ( is the number of the test case, from to ). Then output the number of substrings of that do not contain any virus.
Samples
3
aabc
0
aabbaa
1
a
abcdefg
2
bcd
ef
Case #1: 10
Case #2: 3
Case #3: 14
Note
A substring of a string is a continuous string taken from . For example if we take out the letters from the to the of the string, then the substring will be ().
The original string is a substring of itself.
When we say string contains
string , it means that is a substring of .
Resources
The 11th UESTC Programming Contest Final