The National Security Agency of ByteLand has decided to clamp down on free and unrestricted media. They have decided to form a new language - Reducto, which removes all occurrences of some specified words from any string. Note that the words are to be removed iteratively i.e.the new string resulting from the removal of a word from a string may have newer occurrences of restricted words.(For more details see Sample Input and Output).

Your job is to write a program doing the reduction on a string for them. You have to minimise the length of the resulting string.

Input:
The first line contains the number of test cases T.T lines follow each with a test case. Each Test case begins with the integer N followed by the string S to be reduced, followed by N strings, each representing a restricted word.

Output:
For each test case output the length of the final resulting string.

Constraints:
1<=T<=150
1<=N<=50
Length of S is atmost 50 characters

Sample Input:
3
2 acmmcacamapapc mca pa
1 ccdedefcde cde
2 aabaab aa bb

Sample Output:
6
1
0

Possible reductions for the sample inputs are:
acmmcacamapapc-> acmcamapapc -> acmapapc -> acmapc
ccdedefcde -> cdefcde -> fcde -> f
aabaab -> aabb -> aa -> 'Empty String'

Loading Editor...
  1. Challenge Walkthrough
    Let's walk through this sample challenge and explore the features of the code editor.1 of 6
  2. Review the problem statement
    Each challenge has a problem statement that includes sample inputs and outputs. Some challenges include additional information to help you out.2 of 6
  3. Choose a language
    Select the language you wish to use to solve this challenge.3 of 6
  4. Enter your code
    Code your solution in our custom editor or code in your own environment and upload your solution as a file.4 of 6
  5. Test your code
    You can compile your code and test it for errors and accuracy before submitting.5 of 6
  6. Submit to see results
    When you're ready, submit your solution! Remember, you can go back and refine your code anytime.6 of 6
  1. Check your score