#P1762. JudgingFillingProblems

JudgingFillingProblems

Yiyi is trying to develop an examine system. He finds it not so easyto judge filling question. There may be multiple answers for a blank, Forexample, The 2008 Olympic games was hold in ____CityThe answer can be “Beijing”, and itcan also be “Peking”, he made the answer like this: Beijing(Peking), whichmeans that Beijing, Peking are both correct answers; A filling question mayhave several blanks, For some problems those blanks should be answered inorder, for example, The 2000, 2004 Olympic games was hold respectively in____City and ____City, The answer should be “Sydney Athens”; For other problems those blanks don’t need beanswered in order, for example, ACRush has taken part in the ICPC world finalsin the year ____ and ____, The answer could be “2007|<st1:chmetcnv tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="2009" unitname="”" w:st="on">2009”</st1:chmetcnv>, and it can also be “2009|<st1:chmetcnv tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="2007" unitname="”" w:st="on">2007”</st1:chmetcnv>. Now you are required to help him to write aprogram to judge the filling problems.

Input

The first line contains an integer N, indicate the number of problems. The following N*3 lines, each 3 lines indicate a filling problem, the first line is the question, the second line is the answer(There will not be a answer contains ‘|’, ’(‘, ’)’ for every blank, For one problem every neighboring blanks are separated by “|” ), the third line indicate if the blanks should be filled in order, the word “True” means the blanks should be filled in order while “False” means that filling the blanks in order is not necessary. The following line contains an integer M, indicate the number of person, each person will fill all the problems, so there follows N*M lines, each N lines indicate a person’s answer for the N problems (There will not be a answer contains ‘|’, ‘(’, ‘)’ for every blank, For one problem every neighboring blanks are separated by “|” ), according to the sequence of the N problems.

Output

There are M lines, for each person, write the number of blanks he/she filled correctly.

Sample Input

3
The 2004, 2008 Olympic games was hold respectively in ____City and ____City.
Athens|Beijing(Peking)
True
ACRush has taken part in the ICPC world finals in the year ____ and ____.
2007|2009
False
Aaaa____bbbb_____.
Ccc(cc)|Ddd(dd)
False
2
Athens|Beijing
2007|2009
Dd|cc
Beijing|Athens
2009|2008
Ddd|cc

Sample Output

</p>
5
3

HINT

For each question , any two of the blanks have different answers.

Source