DMOPC '19 Contest 5 P1 - Conspicuous Cryptic Checklist

View as PDF

Submit solution


Points: 5
Time limit: 2.0s
Memory limit: 128M

Author:
Problem types

Tzak has spent the weekend hastily preparing DMOPC problems! Unfortunately, he is now behind on several assignments. After rummaging through his backpack, he realizes that he has N items. To save space, he records the i-th item as a string, s_i, on his checklist. He has M upcoming assignments, the i-th of which requires T_i items to complete, r_1, r_2, \dots, r_{T_i}. If Tzak has all T_i required items, he can complete the i-th assignment. Otherwise, he flunks it. Help him determine how many assignments he can complete!

Constraints

In all subtasks,
1 \le N, M, T_i \le 200
1 \le |s_i|, |r_i| \le 10 where |S| denotes the length of string S

Input Specification

The first line contains two space-separated integers, N and M.
The next N lines contain a single string, s_i. It is guaranteed that all the strings will be unique.
The next M sections contain a single integer T_i, followed by T_i lines each containing a single string, r_i.

Output Specification

Output a single integer on a single line, the answer to the problem.

Sample Input

3 4
chalk
cheese
charger
1
cheese
2
coins
cash
3
charger
chalk
caffeine
3
cheese
charger
cheese

Sample Output

2

Comments

There are no comments at the moment.