Too Many Repetitions
Pappu G of the famous C Party recently faced an interview. But as expected of him, he had studied only few words like RTI, women empowerment, youth, open system etc. He used these words so often in the interview that the audience mocked at him after the interview. Pappu G got very upset with all these and decided to analyze his interview. Of course he knows nothing and has so asked you to write a program to calculate the frequency of each of his words.
Given a sentence S, and Q words, you need to find out the count of each of those words in the interview.
The first line of the input consists of the number of cases (T). T test cases follows. Each test case begins with line with the sentence (S). The sentence consists of upper case and lower case English alphabets only. Next line indicates the number of queries (Q). Next Q lines have a word each whose count you need to find in the sentence.
For each test case, output Q lines, one for each query which is the count of the word.
T ≤ 50
1 ≤|S| ≤10000
Q ≤ 100
1 ≤ |word| ≤10000
2 RTIWomenRTIYouthRTI 5 Country RTI Women Youth rti PPP 1 PP
0 3 1 1 0 2
- In the first case, we have 3 occurrences of "RTI" and 1 each for "Women" and "Youth". Note that words are case sensitive. After all Pappu G is a sensitive person. So "rti" has 0 frequency.
- In the second case, "PP" has 2 occurrence. Note that words may overlap.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, GO|
Fetching successful submissions