In the courses of C programming, the teacher assigns an amusing problem to Flymouse: A string consists of several small lowercases. You should divide the string into several parts. Each part is called a word. The teacher hopes that the number of words is as small as possible. Of course, she will give you a ?dictionary?. Flymouse is puzzled with this problem for a long time. So he asks for your help again ^_^
The input includes several cases. The first line contains a single integer T, the number of test cases. For each test case, the first line contains the string you are to divide, whose length is not larger than 256, the second line contains a single integer N (1<=N<=100), The following N lines are the dictionary, which the teacher gives to you. Every line contains a word.You can assure the string in the first line of each test case can always be divided into several words in the directory.
There should be one output line per test case containing the minimum number of parts.
