Avoiding Partitions#3077

Avoiding Partitions

1 second
64 megabytes
Easy

A partition of the set S = \{1, 2, \ldots, n\} is a collection of sets P = \{P_1, P_2, \ldots, P_k\} such that the union of all P_i is , and any two different P_i and P_j do not intersect, that is, P_i \cap P_j = \varnothing for i \ne j. For example, for n = 5, a partition can be P_1 = \{1, 3\}, P_2 = \{2, 4, 5\}.

A partition is said to avoid a set if none of the P_i contain as a subset. For example, the partition above avoids the sets and , but does not avoid or .

Given and a collection of sets Q_1, Q_2, \ldots, Q_l, find the number of partitions of set that avoid each Q_i.

Input

The first line contains two integers and (1 \le n \le 100, 0 \le l \le 10). The following lines describe the sets to avoid. Each line starts with an integer q_i — the size of the set, followed by q_i numbers — the elements of the set.

Output

Output a single integer — the number of partitions that avoid each Q_i.

Examples

Example 1

Loading
Loading