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, si, on his checklist. He has M upcoming assignments, the i-th of which requires Ti items to complete, r1,r2,,rTi. If Tzak has all Ti 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,
1N,M,Ti200
1|si|,|ri|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, si. It is guaranteed that all the strings will be unique.
The next M sections contain a single integer Ti, followed by Ti lines each containing a single string, ri.

Output Specification

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

Sample Input

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

Sample Output

Copy
2

Comments


  • 0
    cyberboost  commented on April 5, 2024, 11:44 p.m.

    can u have multiple of the same item?


    • 0
      ncai29  commented 86 days ago edited

      yes you can have multiple of the same item