eolymp
bolt
Try our new interface for solving problems
Problems

Mafia game

Mafia game

Phineas and Ferb decide to hold a Mafia championship in Denville.

The game has two roles - civilians and the mafia (there may be several of those). Roles are assigned to players at the very beginning of the game, after which each player with the role of a civilian knows only his role, but does not know the role of other players, while each player with the role of the mafia knows the roles of all other players.

Then several rounds (nights) are played: every night some pairs of players meet each other. And at the end of the night, one victim is announced, who was killed by the mafia that night. Every night, the mafia kills exactly one civilian, and exactly one of the mafia does it. In order for a mafia representative to kill a civilian, a meeting had to take place between them.

Candace has been watching the game so she knows the number of players and the number and description of all nights.

Help her find the minimum possible number of mafia representatives in the game, in which the game could follow the scenario known to her in order to tell her mother about the dangerous activities of Phineas and Ferb.

Input

The first line contains two integers k and m (2k200, 1m ≤ * 200, *1k - m15) - the number of players and number of nights in the game.

Next comes m blocks describing the nights. The description of the i-th night starts with t blocks - the description of alive players (t is the number of players alive at the start of the i-th night). Each block consists of two lines:

  • The first line contains two integers n and c (1nk, 0ct - 1) - the number of player and the number of his meetings that night.
  • The second line contains c positive integers - the numbers of the players that player number n has met.

It is guaranteed that all meetings were bilateral. That is, if player number a is in the list of meetings with player number b, then player b is also in the list with player a.

The last line of the description of the night contains the integer v - the number of the player who was killed that night. It is guaranteed that the input data describes a correct game.

Output

Print a single integer - the minimum number of players that must play the mafia game in order for the described game can take place.

Time limit 2 seconds
Memory limit 128 MiB
Input example #1
4 2
1 3
2 3 4
2 3
1 3 4
3 3
1 2 4
4 3
1 2 3
1
2 2
3 4
3 2
2 4
4 2
2 3
2
Output example #1
1
Source 2020 Cycle of Internet Olympiads for schoolchildren, Third team contest, Novemver 7, Problem C