问题2437--English word

2437: English word

[命题人 : ]
时间限制 : 1.000 sec  内存限制 : 64 MB

题目描述

You still are worried about reading acm English problem, let me tell you a kind of very good method of Memorising Words, the root memory method,.the most interesting of the method is the prefix root. Now there are some English words to remembeand he knows some prefix root;He want to know how many words that can be remembered using each the prefix .in other words,how many words that contain the prefix ,Now to acmer you for help, can you help him?

输入

The input consists of T test cases. The number of them (T) is given on the first line of the input file. Each test case begins with a line containing a single integer number N that indicates the number of words (1 <= N <= 10000). Then exactly N lines follow, each containing a single word. Each word contains at least two and at most 10 lowercase characters, that means only letters 'a' through 'z' will appear in the word. The same word may appear several times in the list. Then follow a line containing a single integer number M that indicates the number of Words prefix question (0 <= M<= 10000). Then exactly M lines follow, each containing a single Words prefix.

输出

For the given input data, output exact M line, each line contain a ingle integer indicates the answer of each query.

样例输入 Copy

1
4
preview
predict
premier
press
3
pre
press
pree

样例输出 Copy

4
1
0

来源/分类