#C117. Maximum Team Task Assignment

    ID: 41044 Type: Default 1000ms 256MiB

Maximum Team Task Assignment

Maximum Team Task Assignment

In this problem, you are given ( n ) team members and ( m ) tasks. Each team member possesses a set of skills, and each task requires a certain set of skills. A team member can perform a task if and only if the set of skills required by the task is a subset of the skills that the team member has. Note that each team member can work on at most one task and each task can be assigned to at most one team member.

Formally, let ( S_i ) be the skill set of the ( i\text{-th} ) team member and ( R_j ) be the required skill set of the ( j\text{-th} ) task. A team member ( i ) can handle task ( j ) if and only if ( R_j \subseteq S_i ). Your goal is to determine the maximum number of tasks that can be assigned under these constraints.

inputFormat

The input is given via standard input (stdin) and has the following format:

  • The first line contains two space-separated integers ( n ) and ( m ) (( 1 \leq n, m \leq 100 )), representing the number of team members and the number of tasks respectively.
  • The next ( n ) lines describe the skills for each team member. Each line starts with an integer ( k ) (the number of skills the team member has), followed by ( k ) space-separated strings denoting the skills.
  • The following ( m ) lines describe the task requirements. Each line starts with an integer ( l ) (the number of required skills for the task), followed by ( l ) space-separated strings representing the required skills.

outputFormat

Output a single integer on standard output (stdout): the maximum number of tasks that can be assigned such that each team member handles at most one task and each task is assigned to at most one team member.## sample

3 3
2 python sql
2 java python
2 sql html
1 python
2 java python
1 html
3