#K53822. Taco Invitations Minimization

    ID: 29617 Type: Default 1000ms 256MiB

Taco Invitations Minimization

Taco Invitations Minimization

You are organizing a taco party and have N individuals available to invite. There are M groups of friends, and each group is represented by a list of individuals. Your task is to select a minimum number of individuals to invite such that every group has at least one member attending the party.

Input Format: The input is provided via stdin. The first line contains two integers N and M separated by a space. The following M lines each describe a group. Each group description starts with an integer k (the number of members in the group), followed by k space‐separated integers representing the indices of individuals in that group.

Output Format: Output a single integer representing the minimal number of invitations required such that every group has at least one invitee. The output should be written to stdout.

The problem can be modeled mathematically as follows. Given a set of individuals \( \{0, 1, \dots, N-1\} \) and groups \( G_1, G_2, \dots, G_M \) with \( G_i \subseteq \{0,1,\dots, N-1\} \), find the smallest subset \( S \) such that for every group \( G_i \), \( S \cap G_i \neq \emptyset \). This can be expressed using the condition:

[ \bigwedge_{i=1}^{M} \left( \bigvee_{j \in G_i} [j \in S] \right) ]

inputFormat

The first line of input contains two integers N (the total number of individuals) and M (the number of groups). This is followed by M lines, one for each group. Each such line begins with an integer k, indicating the number of members in that group, followed by k space-separated integers (each in the range 0 to N-1) representing the members of the group.

outputFormat

Print a single integer which is the minimal number of invitations needed such that every group has at least one member attending.

## sample
5 3
2 0 1
3 1 2 3
2 3 4
2