Input will begin with a line containing a single integer, N representing the number of cases to process. Each case will being with a line with a single integer, O, representing the number of symbols in the case. The next O lines will contain one element per line. The next line will contain a single integer, P representing the number of words to process in this case. The next P lines contain one word each. O and P as well as the length of any element or name will be less than 5000.
<Number of cases>
<number of elements>
<elements...>
<number of words>
<words...>