cho.sh
Notes
Loading...

Cow Pizza

Time limit

2s

Memory limit

128 MB

Problem

The cows like pizza, and they also enjoy choosing from many topping combinations. A pizza shop offers T toppings, numbered from 1 to T.

Some topping combinations are unacceptable to the cows. Each constraint is a set of topping numbers that must not all appear together. If a pizza contains every topping from any one constraint, that pizza is not counted as possible.

Count how many topping combinations can be made, including the pizza with no toppings.

Input

  • The first line contains two space-separated integers T and N. 1 <= T <= 20 and 1 <= N <= 52.
  • Each of the next N lines describes one constraint. The first integer on the line is Z, the number of toppings in the constraint. 1 <= Z <= T.
  • The following Z integers are the topping numbers whose joint presence makes a pizza impossible. The topping numbers in one constraint are distinct.

Output

  • Output one integer: the number of possible pizza topping combinations.