cho.sh
Notes
Loading...

Lies

Time limit

2s

Memory limit

128 MB

Problem

Jimin tells his favorite story whenever he goes to a party. He can tell the story exactly as it happened, or he can make it much more exaggerated for fun. He wants to exaggerate at as many parties as possible, but he must not become known as a liar.

Some people know the truth about the story. If any of them attends a party, Jimin must tell the truth at that party. Also, if one person hears the truth at one party and an exaggerated version at another party, Jimin will be known as a liar. Therefore, in front of anyone connected through parties to a person who knows the truth, he must eventually tell only the truth.

You are given the number of people N, the number of parties M, the people who know the truth, and the attendee list for each party. Jimin attends every party. Find the maximum number of parties where he can exaggerate without becoming known as a liar.

Input

The first line contains the number of people N and the number of parties M.

The second line contains the number of people who know the truth, followed by their numbers. The count is given first, then exactly that many person numbers follow. People are numbered from 1 to N.

Each of the next M lines describes one party in the same format: the number of attendees, followed by the attendee numbers.

N and M are natural numbers at most 50. The number of people who know the truth is an integer from 0 to 50, and the number of attendees at each party is an integer from 1 to 50.

Output

Print one integer: the maximum number of parties where Jimin can exaggerate.